diff --git a/.gitignore b/.gitignore index d28101f9..e8b9955f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ **/node_modules **/dist .turbo -.npmrc \ No newline at end of file +.npmrc +*.pem +openapitools.json \ No newline at end of file diff --git a/examples/php-api-client/README.md b/examples/php-api-client/README.md new file mode 100644 index 00000000..b89ee1a7 --- /dev/null +++ b/examples/php-api-client/README.md @@ -0,0 +1,32 @@ +# Example PHP API client for the AIA Carbon Calculators API + +This example shows how to call the REST API available at https://emissionscalculator-mtls.production.aiaapi.com/calculator/3.0.0 using a simple PHP script. + +## Running the example + +You can execute a simple request to the `beef` endpoint using the example provided. You just need to update the calls `$config->setCertFile` and `$config->setKeyFile` in [example.php](./api-client/example.php) so they point to your client certificate and key files. This allows the client to authenticate with the endpoint via mTLS. Once that has been done you just need to run: + +``` +cd api-client +composer install +php example.php +``` + +## Code generation + +The PHP API client has been generated using the [openapi-generator-cli](https://www.npmjs.com/package/@openapitools/openapi-generator-cli) tool. The generation can be reproduced with a script like: + +``` +API_CLIENT_DIR=api-client +API_VERSION=3.0.0 +rm -rf $API_CLIENT_DIR + +npm -g install @openapitools/openapi-generator-cli +openapi-generator-cli generate \ + -i https://d2awla29kxgk7i.cloudfront.net/api/$API_VERSION/openapi.json \ + -g php \ + -o $API_CLIENT_DIR \ + --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false +``` + +For now, the PHP generator does not support all the configuration needed for an mTLS connection out of the box. Several fixes have been applied to the generated code in the `api-client` folder to let this work end to end. Once this [PR](https://github.com/OpenAPITools/openapi-generator/pull/22229) has been merged and released, it will be possible to make requests via mTLS without any code changes to the generated PHP client code needed. diff --git a/examples/php-api-client/api-client/.gitignore b/examples/php-api-client/api-client/.gitignore new file mode 100644 index 00000000..9f1681c2 --- /dev/null +++ b/examples/php-api-client/api-client/.gitignore @@ -0,0 +1,15 @@ +# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore + +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock + +# php-cs-fixer cache +.php_cs.cache +.php-cs-fixer.cache + +# PHPUnit cache +.phpunit.result.cache diff --git a/examples/php-api-client/api-client/.openapi-generator-ignore b/examples/php-api-client/api-client/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/examples/php-api-client/api-client/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/examples/php-api-client/api-client/.openapi-generator/FILES b/examples/php-api-client/api-client/.openapi-generator/FILES new file mode 100644 index 00000000..be621d80 --- /dev/null +++ b/examples/php-api-client/api-client/.openapi-generator/FILES @@ -0,0 +1,306 @@ +.gitignore +.openapi-generator-ignore +.php-cs-fixer.dist.php +.travis.yml +README.md +composer.json +git_push.sh +lib/Api/GAFApi.php +lib/ApiException.php +lib/Configuration.php +lib/FormDataProcessor.php +lib/HeaderSelector.php +lib/Model/ModelInterface.php +lib/Model/PostAquaculture200Response.php +lib/Model/PostAquaculture200ResponseCarbonSequestration.php +lib/Model/PostAquaculture200ResponseIntensities.php +lib/Model/PostAquaculture200ResponseIntermediateInner.php +lib/Model/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.php +lib/Model/PostAquaculture200ResponseNet.php +lib/Model/PostAquaculture200ResponsePurchasedOffsets.php +lib/Model/PostAquaculture200ResponseScope1.php +lib/Model/PostAquaculture200ResponseScope2.php +lib/Model/PostAquaculture200ResponseScope3.php +lib/Model/PostAquacultureRequest.php +lib/Model/PostAquacultureRequestEnterprisesInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerBaitInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerCustomBaitInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerFluidWasteInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerFuel.php +lib/Model/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerInboundFreightInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.php +lib/Model/PostAquacultureRequestEnterprisesInnerSolidWaste.php +lib/Model/PostBeef200Response.php +lib/Model/PostBeef200ResponseIntermediateInner.php +lib/Model/PostBeef200ResponseIntermediateInnerIntensities.php +lib/Model/PostBeef200ResponseNet.php +lib/Model/PostBeef200ResponseScope1.php +lib/Model/PostBeef200ResponseScope3.php +lib/Model/PostBeefRequest.php +lib/Model/PostBeefRequestBeefInner.php +lib/Model/PostBeefRequestBeefInnerClasses.php +lib/Model/PostBeefRequestBeefInnerClassesBullsGt1.php +lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Autumn.php +lib/Model/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.php +lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Traded.php +lib/Model/PostBeefRequestBeefInnerClassesCowsGt2.php +lib/Model/PostBeefRequestBeefInnerClassesCowsGt2Traded.php +lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2.php +lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2Traded.php +lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2.php +lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2Traded.php +lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1.php +lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1Traded.php +lib/Model/PostBeefRequestBeefInnerClassesSteers1To2.php +lib/Model/PostBeefRequestBeefInnerClassesSteers1To2Traded.php +lib/Model/PostBeefRequestBeefInnerClassesSteersGt2.php +lib/Model/PostBeefRequestBeefInnerClassesSteersGt2Traded.php +lib/Model/PostBeefRequestBeefInnerClassesSteersLt1.php +lib/Model/PostBeefRequestBeefInnerClassesSteersLt1Traded.php +lib/Model/PostBeefRequestBeefInnerCowsCalving.php +lib/Model/PostBeefRequestBeefInnerFertiliser.php +lib/Model/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.php +lib/Model/PostBeefRequestBeefInnerMineralSupplementation.php +lib/Model/PostBeefRequestBurningInner.php +lib/Model/PostBeefRequestBurningInnerBurning.php +lib/Model/PostBeefRequestVegetationInner.php +lib/Model/PostBeefRequestVegetationInnerVegetation.php +lib/Model/PostBuffalo200Response.php +lib/Model/PostBuffalo200ResponseIntensities.php +lib/Model/PostBuffalo200ResponseIntermediateInner.php +lib/Model/PostBuffalo200ResponseNet.php +lib/Model/PostBuffalo200ResponseScope1.php +lib/Model/PostBuffalo200ResponseScope3.php +lib/Model/PostBuffaloRequest.php +lib/Model/PostBuffaloRequestBuffalosInner.php +lib/Model/PostBuffaloRequestBuffalosInnerClasses.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesBulls.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesCalfs.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesCows.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesSteers.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeBulls.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCows.php +lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeSteers.php +lib/Model/PostBuffaloRequestBuffalosInnerCowsCalving.php +lib/Model/PostBuffaloRequestBuffalosInnerSeasonalCalving.php +lib/Model/PostBuffaloRequestVegetationInner.php +lib/Model/PostCotton200Response.php +lib/Model/PostCotton200ResponseIntermediateInner.php +lib/Model/PostCotton200ResponseIntermediateInnerIntensities.php +lib/Model/PostCotton200ResponseNet.php +lib/Model/PostCotton200ResponseScope1.php +lib/Model/PostCotton200ResponseScope3.php +lib/Model/PostCottonRequest.php +lib/Model/PostCottonRequestCropsInner.php +lib/Model/PostCottonRequestVegetationInner.php +lib/Model/PostDairy200Response.php +lib/Model/PostDairy200ResponseIntensities.php +lib/Model/PostDairy200ResponseIntermediateInner.php +lib/Model/PostDairy200ResponseNet.php +lib/Model/PostDairy200ResponseScope1.php +lib/Model/PostDairy200ResponseScope3.php +lib/Model/PostDairyRequest.php +lib/Model/PostDairyRequestDairyInner.php +lib/Model/PostDairyRequestDairyInnerAreas.php +lib/Model/PostDairyRequestDairyInnerClasses.php +lib/Model/PostDairyRequestDairyInnerClassesDairyBullsGt1.php +lib/Model/PostDairyRequestDairyInnerClassesDairyBullsLt1.php +lib/Model/PostDairyRequestDairyInnerClassesHeifersGt1.php +lib/Model/PostDairyRequestDairyInnerClassesHeifersLt1.php +lib/Model/PostDairyRequestDairyInnerClassesMilkingCows.php +lib/Model/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.php +lib/Model/PostDairyRequestDairyInnerManureManagementMilkingCows.php +lib/Model/PostDairyRequestDairyInnerSeasonalFertiliser.php +lib/Model/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.php +lib/Model/PostDairyRequestVegetationInner.php +lib/Model/PostDeer200Response.php +lib/Model/PostDeer200ResponseIntensities.php +lib/Model/PostDeer200ResponseIntermediateInner.php +lib/Model/PostDeer200ResponseNet.php +lib/Model/PostDeerRequest.php +lib/Model/PostDeerRequestDeersInner.php +lib/Model/PostDeerRequestDeersInnerClasses.php +lib/Model/PostDeerRequestDeersInnerClassesBreedingDoes.php +lib/Model/PostDeerRequestDeersInnerClassesBucks.php +lib/Model/PostDeerRequestDeersInnerClassesFawn.php +lib/Model/PostDeerRequestDeersInnerClassesOtherDoes.php +lib/Model/PostDeerRequestDeersInnerClassesTradeBucks.php +lib/Model/PostDeerRequestDeersInnerClassesTradeDoes.php +lib/Model/PostDeerRequestDeersInnerClassesTradeFawn.php +lib/Model/PostDeerRequestDeersInnerClassesTradeOtherDoes.php +lib/Model/PostDeerRequestDeersInnerDoesFawning.php +lib/Model/PostDeerRequestDeersInnerSeasonalFawning.php +lib/Model/PostDeerRequestVegetationInner.php +lib/Model/PostFeedlot200Response.php +lib/Model/PostFeedlot200ResponseIntermediateInner.php +lib/Model/PostFeedlot200ResponseIntermediateInnerIntensities.php +lib/Model/PostFeedlot200ResponseIntermediateInnerNet.php +lib/Model/PostFeedlot200ResponseScope1.php +lib/Model/PostFeedlot200ResponseScope3.php +lib/Model/PostFeedlotRequest.php +lib/Model/PostFeedlotRequestFeedlotsInner.php +lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInner.php +lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.php +lib/Model/PostFeedlotRequestFeedlotsInnerPurchases.php +lib/Model/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.php +lib/Model/PostFeedlotRequestFeedlotsInnerSales.php +lib/Model/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.php +lib/Model/PostFeedlotRequestVegetationInner.php +lib/Model/PostGoat200Response.php +lib/Model/PostGoat200ResponseIntensities.php +lib/Model/PostGoat200ResponseIntermediateInner.php +lib/Model/PostGoat200ResponseNet.php +lib/Model/PostGoatRequest.php +lib/Model/PostGoatRequestGoatsInner.php +lib/Model/PostGoatRequestGoatsInnerClasses.php +lib/Model/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.php +lib/Model/PostGoatRequestGoatsInnerClassesBucksBilly.php +lib/Model/PostGoatRequestGoatsInnerClassesKids.php +lib/Model/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.php +lib/Model/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeBucks.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeDoes.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeKids.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.php +lib/Model/PostGoatRequestGoatsInnerClassesTradeWethers.php +lib/Model/PostGoatRequestGoatsInnerClassesWethers.php +lib/Model/PostGoatRequestVegetationInner.php +lib/Model/PostGrains200Response.php +lib/Model/PostGrains200ResponseIntermediateInner.php +lib/Model/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.php +lib/Model/PostGrainsRequest.php +lib/Model/PostGrainsRequestCropsInner.php +lib/Model/PostHorticulture200Response.php +lib/Model/PostHorticulture200ResponseIntermediateInner.php +lib/Model/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.php +lib/Model/PostHorticulture200ResponseScope1.php +lib/Model/PostHorticultureRequest.php +lib/Model/PostHorticultureRequestCropsInner.php +lib/Model/PostHorticultureRequestCropsInnerRefrigerantsInner.php +lib/Model/PostPork200Response.php +lib/Model/PostPork200ResponseIntensities.php +lib/Model/PostPork200ResponseIntermediateInner.php +lib/Model/PostPork200ResponseNet.php +lib/Model/PostPork200ResponseScope1.php +lib/Model/PostPork200ResponseScope3.php +lib/Model/PostPorkRequest.php +lib/Model/PostPorkRequestPorkInner.php +lib/Model/PostPorkRequestPorkInnerClasses.php +lib/Model/PostPorkRequestPorkInnerClassesBoars.php +lib/Model/PostPorkRequestPorkInnerClassesGilts.php +lib/Model/PostPorkRequestPorkInnerClassesGrowers.php +lib/Model/PostPorkRequestPorkInnerClassesSlaughterPigs.php +lib/Model/PostPorkRequestPorkInnerClassesSows.php +lib/Model/PostPorkRequestPorkInnerClassesSowsManure.php +lib/Model/PostPorkRequestPorkInnerClassesSowsManureSpring.php +lib/Model/PostPorkRequestPorkInnerClassesSuckers.php +lib/Model/PostPorkRequestPorkInnerClassesWeaners.php +lib/Model/PostPorkRequestPorkInnerFeedProductsInner.php +lib/Model/PostPorkRequestPorkInnerFeedProductsInnerIngredients.php +lib/Model/PostPorkRequestVegetationInner.php +lib/Model/PostPoultry200Response.php +lib/Model/PostPoultry200ResponseIntensities.php +lib/Model/PostPoultry200ResponseIntermediateBroilersInner.php +lib/Model/PostPoultry200ResponseIntermediateBroilersInnerIntensities.php +lib/Model/PostPoultry200ResponseIntermediateLayersInner.php +lib/Model/PostPoultry200ResponseIntermediateLayersInnerIntensities.php +lib/Model/PostPoultry200ResponseNet.php +lib/Model/PostPoultry200ResponseScope1.php +lib/Model/PostPoultry200ResponseScope3.php +lib/Model/PostPoultryRequest.php +lib/Model/PostPoultryRequestBroilersInner.php +lib/Model/PostPoultryRequestBroilersInnerGroupsInner.php +lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.php +lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.php +lib/Model/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.php +lib/Model/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.php +lib/Model/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.php +lib/Model/PostPoultryRequestBroilersInnerMeatOtherPurchases.php +lib/Model/PostPoultryRequestBroilersInnerSalesInner.php +lib/Model/PostPoultryRequestLayersInner.php +lib/Model/PostPoultryRequestLayersInnerLayers.php +lib/Model/PostPoultryRequestLayersInnerLayersEggSale.php +lib/Model/PostPoultryRequestLayersInnerLayersPurchases.php +lib/Model/PostPoultryRequestLayersInnerMeatChickenLayers.php +lib/Model/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.php +lib/Model/PostPoultryRequestVegetationInner.php +lib/Model/PostProcessing200Response.php +lib/Model/PostProcessing200ResponseIntensitiesInner.php +lib/Model/PostProcessing200ResponseIntermediateInner.php +lib/Model/PostProcessing200ResponseNet.php +lib/Model/PostProcessing200ResponseScope1.php +lib/Model/PostProcessing200ResponseScope3.php +lib/Model/PostProcessingRequest.php +lib/Model/PostProcessingRequestProductsInner.php +lib/Model/PostProcessingRequestProductsInnerProduct.php +lib/Model/PostRice200Response.php +lib/Model/PostRice200ResponseIntensities.php +lib/Model/PostRice200ResponseIntermediateInner.php +lib/Model/PostRice200ResponseIntermediateInnerIntensities.php +lib/Model/PostRice200ResponseScope1.php +lib/Model/PostRiceRequest.php +lib/Model/PostRiceRequestCropsInner.php +lib/Model/PostSheep200Response.php +lib/Model/PostSheep200ResponseIntermediateInner.php +lib/Model/PostSheep200ResponseIntermediateInnerIntensities.php +lib/Model/PostSheep200ResponseNet.php +lib/Model/PostSheepRequest.php +lib/Model/PostSheepRequestSheepInner.php +lib/Model/PostSheepRequestSheepInnerClasses.php +lib/Model/PostSheepRequestSheepInnerClassesRams.php +lib/Model/PostSheepRequestSheepInnerClassesRamsAutumn.php +lib/Model/PostSheepRequestSheepInnerClassesTradeEwes.php +lib/Model/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.php +lib/Model/PostSheepRequestSheepInnerEwesLambing.php +lib/Model/PostSheepRequestSheepInnerSeasonalLambing.php +lib/Model/PostSheepRequestVegetationInner.php +lib/Model/PostSheepbeef200Response.php +lib/Model/PostSheepbeef200ResponseIntensities.php +lib/Model/PostSheepbeef200ResponseIntermediate.php +lib/Model/PostSheepbeef200ResponseIntermediateBeef.php +lib/Model/PostSheepbeef200ResponseIntermediateSheep.php +lib/Model/PostSheepbeef200ResponseNet.php +lib/Model/PostSheepbeefRequest.php +lib/Model/PostSheepbeefRequestVegetationInner.php +lib/Model/PostSugar200Response.php +lib/Model/PostSugar200ResponseIntermediateInner.php +lib/Model/PostSugar200ResponseIntermediateInnerIntensities.php +lib/Model/PostSugarRequest.php +lib/Model/PostSugarRequestCropsInner.php +lib/Model/PostVineyard200Response.php +lib/Model/PostVineyard200ResponseIntermediateInner.php +lib/Model/PostVineyard200ResponseIntermediateInnerIntensities.php +lib/Model/PostVineyard200ResponseNet.php +lib/Model/PostVineyard200ResponseScope1.php +lib/Model/PostVineyard200ResponseScope3.php +lib/Model/PostVineyardRequest.php +lib/Model/PostVineyardRequestVegetationInner.php +lib/Model/PostVineyardRequestVineyardsInner.php +lib/Model/PostWildcatchfishery200Response.php +lib/Model/PostWildcatchfishery200ResponseIntensities.php +lib/Model/PostWildcatchfishery200ResponseIntermediateInner.php +lib/Model/PostWildcatchfishery200ResponseScope1.php +lib/Model/PostWildcatchfisheryRequest.php +lib/Model/PostWildcatchfisheryRequestEnterprisesInner.php +lib/Model/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.php +lib/Model/PostWildseafisheries200Response.php +lib/Model/PostWildseafisheries200ResponseIntermediateInner.php +lib/Model/PostWildseafisheries200ResponseIntermediateInnerIntensities.php +lib/Model/PostWildseafisheries200ResponseScope1.php +lib/Model/PostWildseafisheries200ResponseScope3.php +lib/Model/PostWildseafisheriesRequest.php +lib/Model/PostWildseafisheriesRequestEnterprisesInner.php +lib/Model/PostWildseafisheriesRequestEnterprisesInnerBaitInner.php +lib/Model/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.php +lib/Model/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.php +lib/Model/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.php +lib/Model/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.php +lib/ObjectSerializer.php +phpunit.xml.dist diff --git a/examples/php-api-client/api-client/.openapi-generator/VERSION b/examples/php-api-client/api-client/.openapi-generator/VERSION new file mode 100644 index 00000000..971ecb25 --- /dev/null +++ b/examples/php-api-client/api-client/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.16.0 diff --git a/examples/php-api-client/api-client/.php-cs-fixer.dist.php b/examples/php-api-client/api-client/.php-cs-fixer.dist.php new file mode 100644 index 00000000..af9cf39f --- /dev/null +++ b/examples/php-api-client/api-client/.php-cs-fixer.dist.php @@ -0,0 +1,29 @@ +in(__DIR__) + ->exclude('vendor') + ->exclude('test') + ->exclude('tests') +; + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PSR12' => true, + 'phpdoc_order' => true, + 'array_syntax' => [ 'syntax' => 'short' ], + 'strict_comparison' => true, + 'strict_param' => true, + 'no_trailing_whitespace' => false, + 'no_trailing_whitespace_in_comment' => false, + 'braces' => false, + 'single_blank_line_at_eof' => false, + 'blank_line_after_namespace' => false, + 'no_leading_import_slash' => false, + ]) + ->setFinder($finder) +; diff --git a/examples/php-api-client/api-client/.travis.yml b/examples/php-api-client/api-client/.travis.yml new file mode 100644 index 00000000..667b8156 --- /dev/null +++ b/examples/php-api-client/api-client/.travis.yml @@ -0,0 +1,8 @@ +language: php +# Bionic environment has preinstalled PHP from 7.1 to 7.4 +# https://docs.travis-ci.com/user/reference/bionic/#php-support +dist: bionic +php: + - 7.4 +before_install: "composer install" +script: "vendor/bin/phpunit" diff --git a/examples/php-api-client/api-client/README.md b/examples/php-api-client/api-client/README.md new file mode 100644 index 00000000..9d9b32f2 --- /dev/null +++ b/examples/php-api-client/api-client/README.md @@ -0,0 +1,412 @@ +# OpenAPIClient-php + +Emissions Calculators for various farming activities + +For more information, please visit [https://aginnovationaustralia.com.au/contact-us/](https://aginnovationaustralia.com.au/contact-us/). + +## Installation & Usage + +### Requirements + +PHP 8.1 and later. + +### Composer + +To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`: + +```json +{ + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + } + ], + "require": { + "GIT_USER_ID/GIT_REPO_ID": "*@dev" + } +} +``` + +Then run `composer install` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php +postAquaculture($post_aquaculture_request); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling GAFApi->postAquaculture: ', $e->getMessage(), PHP_EOL; +} + +``` + +## API Endpoints + +All URIs are relative to *https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*GAFApi* | [**postAquaculture**](docs/Api/GAFApi.md#postaquaculture) | **POST** /aquaculture | Perform aquaculture calculation +*GAFApi* | [**postBeef**](docs/Api/GAFApi.md#postbeef) | **POST** /beef | Perform beef calculation +*GAFApi* | [**postBuffalo**](docs/Api/GAFApi.md#postbuffalo) | **POST** /buffalo | Perform buffalo calculation +*GAFApi* | [**postCotton**](docs/Api/GAFApi.md#postcotton) | **POST** /cotton | Perform cotton calculation +*GAFApi* | [**postDairy**](docs/Api/GAFApi.md#postdairy) | **POST** /dairy | Perform dairy calculation +*GAFApi* | [**postDeer**](docs/Api/GAFApi.md#postdeer) | **POST** /deer | Perform deer calculation +*GAFApi* | [**postFeedlot**](docs/Api/GAFApi.md#postfeedlot) | **POST** /feedlot | Perform feedlot calculation +*GAFApi* | [**postGoat**](docs/Api/GAFApi.md#postgoat) | **POST** /goat | Perform goat calculation +*GAFApi* | [**postGrains**](docs/Api/GAFApi.md#postgrains) | **POST** /grains | Perform grains calculation +*GAFApi* | [**postHorticulture**](docs/Api/GAFApi.md#posthorticulture) | **POST** /horticulture | Perform horticulture calculation +*GAFApi* | [**postPork**](docs/Api/GAFApi.md#postpork) | **POST** /pork | Perform pork calculation +*GAFApi* | [**postPoultry**](docs/Api/GAFApi.md#postpoultry) | **POST** /poultry | Perform poultry calculation +*GAFApi* | [**postProcessing**](docs/Api/GAFApi.md#postprocessing) | **POST** /processing | Perform processing calculation +*GAFApi* | [**postRice**](docs/Api/GAFApi.md#postrice) | **POST** /rice | Perform rice calculation +*GAFApi* | [**postSheep**](docs/Api/GAFApi.md#postsheep) | **POST** /sheep | Perform sheep calculation +*GAFApi* | [**postSheepbeef**](docs/Api/GAFApi.md#postsheepbeef) | **POST** /sheepbeef | Perform sheepbeef calculation +*GAFApi* | [**postSugar**](docs/Api/GAFApi.md#postsugar) | **POST** /sugar | Perform sugar calculation +*GAFApi* | [**postVineyard**](docs/Api/GAFApi.md#postvineyard) | **POST** /vineyard | Perform vineyard calculation +*GAFApi* | [**postWildcatchfishery**](docs/Api/GAFApi.md#postwildcatchfishery) | **POST** /wildcatchfishery | Perform wildcatchfishery calculation +*GAFApi* | [**postWildseafisheries**](docs/Api/GAFApi.md#postwildseafisheries) | **POST** /wildseafisheries | Perform wildseafisheries calculation + +## Models + +- [PostAquaculture200Response](docs/Model/PostAquaculture200Response.md) +- [PostAquaculture200ResponseCarbonSequestration](docs/Model/PostAquaculture200ResponseCarbonSequestration.md) +- [PostAquaculture200ResponseIntensities](docs/Model/PostAquaculture200ResponseIntensities.md) +- [PostAquaculture200ResponseIntermediateInner](docs/Model/PostAquaculture200ResponseIntermediateInner.md) +- [PostAquaculture200ResponseIntermediateInnerCarbonSequestration](docs/Model/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.md) +- [PostAquaculture200ResponseNet](docs/Model/PostAquaculture200ResponseNet.md) +- [PostAquaculture200ResponsePurchasedOffsets](docs/Model/PostAquaculture200ResponsePurchasedOffsets.md) +- [PostAquaculture200ResponseScope1](docs/Model/PostAquaculture200ResponseScope1.md) +- [PostAquaculture200ResponseScope2](docs/Model/PostAquaculture200ResponseScope2.md) +- [PostAquaculture200ResponseScope3](docs/Model/PostAquaculture200ResponseScope3.md) +- [PostAquacultureRequest](docs/Model/PostAquacultureRequest.md) +- [PostAquacultureRequestEnterprisesInner](docs/Model/PostAquacultureRequestEnterprisesInner.md) +- [PostAquacultureRequestEnterprisesInnerBaitInner](docs/Model/PostAquacultureRequestEnterprisesInnerBaitInner.md) +- [PostAquacultureRequestEnterprisesInnerCustomBaitInner](docs/Model/PostAquacultureRequestEnterprisesInnerCustomBaitInner.md) +- [PostAquacultureRequestEnterprisesInnerFluidWasteInner](docs/Model/PostAquacultureRequestEnterprisesInnerFluidWasteInner.md) +- [PostAquacultureRequestEnterprisesInnerFuel](docs/Model/PostAquacultureRequestEnterprisesInnerFuel.md) +- [PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner](docs/Model/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.md) +- [PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner](docs/Model/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.md) +- [PostAquacultureRequestEnterprisesInnerInboundFreightInner](docs/Model/PostAquacultureRequestEnterprisesInnerInboundFreightInner.md) +- [PostAquacultureRequestEnterprisesInnerRefrigerantsInner](docs/Model/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.md) +- [PostAquacultureRequestEnterprisesInnerSolidWaste](docs/Model/PostAquacultureRequestEnterprisesInnerSolidWaste.md) +- [PostBeef200Response](docs/Model/PostBeef200Response.md) +- [PostBeef200ResponseIntermediateInner](docs/Model/PostBeef200ResponseIntermediateInner.md) +- [PostBeef200ResponseIntermediateInnerIntensities](docs/Model/PostBeef200ResponseIntermediateInnerIntensities.md) +- [PostBeef200ResponseNet](docs/Model/PostBeef200ResponseNet.md) +- [PostBeef200ResponseScope1](docs/Model/PostBeef200ResponseScope1.md) +- [PostBeef200ResponseScope3](docs/Model/PostBeef200ResponseScope3.md) +- [PostBeefRequest](docs/Model/PostBeefRequest.md) +- [PostBeefRequestBeefInner](docs/Model/PostBeefRequestBeefInner.md) +- [PostBeefRequestBeefInnerClasses](docs/Model/PostBeefRequestBeefInnerClasses.md) +- [PostBeefRequestBeefInnerClassesBullsGt1](docs/Model/PostBeefRequestBeefInnerClassesBullsGt1.md) +- [PostBeefRequestBeefInnerClassesBullsGt1Autumn](docs/Model/PostBeefRequestBeefInnerClassesBullsGt1Autumn.md) +- [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner](docs/Model/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.md) +- [PostBeefRequestBeefInnerClassesBullsGt1Traded](docs/Model/PostBeefRequestBeefInnerClassesBullsGt1Traded.md) +- [PostBeefRequestBeefInnerClassesCowsGt2](docs/Model/PostBeefRequestBeefInnerClassesCowsGt2.md) +- [PostBeefRequestBeefInnerClassesCowsGt2Traded](docs/Model/PostBeefRequestBeefInnerClassesCowsGt2Traded.md) +- [PostBeefRequestBeefInnerClassesHeifers1To2](docs/Model/PostBeefRequestBeefInnerClassesHeifers1To2.md) +- [PostBeefRequestBeefInnerClassesHeifers1To2Traded](docs/Model/PostBeefRequestBeefInnerClassesHeifers1To2Traded.md) +- [PostBeefRequestBeefInnerClassesHeifersGt2](docs/Model/PostBeefRequestBeefInnerClassesHeifersGt2.md) +- [PostBeefRequestBeefInnerClassesHeifersGt2Traded](docs/Model/PostBeefRequestBeefInnerClassesHeifersGt2Traded.md) +- [PostBeefRequestBeefInnerClassesHeifersLt1](docs/Model/PostBeefRequestBeefInnerClassesHeifersLt1.md) +- [PostBeefRequestBeefInnerClassesHeifersLt1Traded](docs/Model/PostBeefRequestBeefInnerClassesHeifersLt1Traded.md) +- [PostBeefRequestBeefInnerClassesSteers1To2](docs/Model/PostBeefRequestBeefInnerClassesSteers1To2.md) +- [PostBeefRequestBeefInnerClassesSteers1To2Traded](docs/Model/PostBeefRequestBeefInnerClassesSteers1To2Traded.md) +- [PostBeefRequestBeefInnerClassesSteersGt2](docs/Model/PostBeefRequestBeefInnerClassesSteersGt2.md) +- [PostBeefRequestBeefInnerClassesSteersGt2Traded](docs/Model/PostBeefRequestBeefInnerClassesSteersGt2Traded.md) +- [PostBeefRequestBeefInnerClassesSteersLt1](docs/Model/PostBeefRequestBeefInnerClassesSteersLt1.md) +- [PostBeefRequestBeefInnerClassesSteersLt1Traded](docs/Model/PostBeefRequestBeefInnerClassesSteersLt1Traded.md) +- [PostBeefRequestBeefInnerCowsCalving](docs/Model/PostBeefRequestBeefInnerCowsCalving.md) +- [PostBeefRequestBeefInnerFertiliser](docs/Model/PostBeefRequestBeefInnerFertiliser.md) +- [PostBeefRequestBeefInnerFertiliserOtherFertilisersInner](docs/Model/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.md) +- [PostBeefRequestBeefInnerMineralSupplementation](docs/Model/PostBeefRequestBeefInnerMineralSupplementation.md) +- [PostBeefRequestBurningInner](docs/Model/PostBeefRequestBurningInner.md) +- [PostBeefRequestBurningInnerBurning](docs/Model/PostBeefRequestBurningInnerBurning.md) +- [PostBeefRequestVegetationInner](docs/Model/PostBeefRequestVegetationInner.md) +- [PostBeefRequestVegetationInnerVegetation](docs/Model/PostBeefRequestVegetationInnerVegetation.md) +- [PostBuffalo200Response](docs/Model/PostBuffalo200Response.md) +- [PostBuffalo200ResponseIntensities](docs/Model/PostBuffalo200ResponseIntensities.md) +- [PostBuffalo200ResponseIntermediateInner](docs/Model/PostBuffalo200ResponseIntermediateInner.md) +- [PostBuffalo200ResponseNet](docs/Model/PostBuffalo200ResponseNet.md) +- [PostBuffalo200ResponseScope1](docs/Model/PostBuffalo200ResponseScope1.md) +- [PostBuffalo200ResponseScope3](docs/Model/PostBuffalo200ResponseScope3.md) +- [PostBuffaloRequest](docs/Model/PostBuffaloRequest.md) +- [PostBuffaloRequestBuffalosInner](docs/Model/PostBuffaloRequestBuffalosInner.md) +- [PostBuffaloRequestBuffalosInnerClasses](docs/Model/PostBuffaloRequestBuffalosInnerClasses.md) +- [PostBuffaloRequestBuffalosInnerClassesBulls](docs/Model/PostBuffaloRequestBuffalosInnerClassesBulls.md) +- [PostBuffaloRequestBuffalosInnerClassesBullsAutumn](docs/Model/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.md) +- [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner](docs/Model/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.md) +- [PostBuffaloRequestBuffalosInnerClassesCalfs](docs/Model/PostBuffaloRequestBuffalosInnerClassesCalfs.md) +- [PostBuffaloRequestBuffalosInnerClassesCows](docs/Model/PostBuffaloRequestBuffalosInnerClassesCows.md) +- [PostBuffaloRequestBuffalosInnerClassesSteers](docs/Model/PostBuffaloRequestBuffalosInnerClassesSteers.md) +- [PostBuffaloRequestBuffalosInnerClassesTradeBulls](docs/Model/PostBuffaloRequestBuffalosInnerClassesTradeBulls.md) +- [PostBuffaloRequestBuffalosInnerClassesTradeCalfs](docs/Model/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.md) +- [PostBuffaloRequestBuffalosInnerClassesTradeCows](docs/Model/PostBuffaloRequestBuffalosInnerClassesTradeCows.md) +- [PostBuffaloRequestBuffalosInnerClassesTradeSteers](docs/Model/PostBuffaloRequestBuffalosInnerClassesTradeSteers.md) +- [PostBuffaloRequestBuffalosInnerCowsCalving](docs/Model/PostBuffaloRequestBuffalosInnerCowsCalving.md) +- [PostBuffaloRequestBuffalosInnerSeasonalCalving](docs/Model/PostBuffaloRequestBuffalosInnerSeasonalCalving.md) +- [PostBuffaloRequestVegetationInner](docs/Model/PostBuffaloRequestVegetationInner.md) +- [PostCotton200Response](docs/Model/PostCotton200Response.md) +- [PostCotton200ResponseIntermediateInner](docs/Model/PostCotton200ResponseIntermediateInner.md) +- [PostCotton200ResponseIntermediateInnerIntensities](docs/Model/PostCotton200ResponseIntermediateInnerIntensities.md) +- [PostCotton200ResponseNet](docs/Model/PostCotton200ResponseNet.md) +- [PostCotton200ResponseScope1](docs/Model/PostCotton200ResponseScope1.md) +- [PostCotton200ResponseScope3](docs/Model/PostCotton200ResponseScope3.md) +- [PostCottonRequest](docs/Model/PostCottonRequest.md) +- [PostCottonRequestCropsInner](docs/Model/PostCottonRequestCropsInner.md) +- [PostCottonRequestVegetationInner](docs/Model/PostCottonRequestVegetationInner.md) +- [PostDairy200Response](docs/Model/PostDairy200Response.md) +- [PostDairy200ResponseIntensities](docs/Model/PostDairy200ResponseIntensities.md) +- [PostDairy200ResponseIntermediateInner](docs/Model/PostDairy200ResponseIntermediateInner.md) +- [PostDairy200ResponseNet](docs/Model/PostDairy200ResponseNet.md) +- [PostDairy200ResponseScope1](docs/Model/PostDairy200ResponseScope1.md) +- [PostDairy200ResponseScope3](docs/Model/PostDairy200ResponseScope3.md) +- [PostDairyRequest](docs/Model/PostDairyRequest.md) +- [PostDairyRequestDairyInner](docs/Model/PostDairyRequestDairyInner.md) +- [PostDairyRequestDairyInnerAreas](docs/Model/PostDairyRequestDairyInnerAreas.md) +- [PostDairyRequestDairyInnerClasses](docs/Model/PostDairyRequestDairyInnerClasses.md) +- [PostDairyRequestDairyInnerClassesDairyBullsGt1](docs/Model/PostDairyRequestDairyInnerClassesDairyBullsGt1.md) +- [PostDairyRequestDairyInnerClassesDairyBullsLt1](docs/Model/PostDairyRequestDairyInnerClassesDairyBullsLt1.md) +- [PostDairyRequestDairyInnerClassesHeifersGt1](docs/Model/PostDairyRequestDairyInnerClassesHeifersGt1.md) +- [PostDairyRequestDairyInnerClassesHeifersLt1](docs/Model/PostDairyRequestDairyInnerClassesHeifersLt1.md) +- [PostDairyRequestDairyInnerClassesMilkingCows](docs/Model/PostDairyRequestDairyInnerClassesMilkingCows.md) +- [PostDairyRequestDairyInnerClassesMilkingCowsAutumn](docs/Model/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.md) +- [PostDairyRequestDairyInnerManureManagementMilkingCows](docs/Model/PostDairyRequestDairyInnerManureManagementMilkingCows.md) +- [PostDairyRequestDairyInnerSeasonalFertiliser](docs/Model/PostDairyRequestDairyInnerSeasonalFertiliser.md) +- [PostDairyRequestDairyInnerSeasonalFertiliserAutumn](docs/Model/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.md) +- [PostDairyRequestVegetationInner](docs/Model/PostDairyRequestVegetationInner.md) +- [PostDeer200Response](docs/Model/PostDeer200Response.md) +- [PostDeer200ResponseIntensities](docs/Model/PostDeer200ResponseIntensities.md) +- [PostDeer200ResponseIntermediateInner](docs/Model/PostDeer200ResponseIntermediateInner.md) +- [PostDeer200ResponseNet](docs/Model/PostDeer200ResponseNet.md) +- [PostDeerRequest](docs/Model/PostDeerRequest.md) +- [PostDeerRequestDeersInner](docs/Model/PostDeerRequestDeersInner.md) +- [PostDeerRequestDeersInnerClasses](docs/Model/PostDeerRequestDeersInnerClasses.md) +- [PostDeerRequestDeersInnerClassesBreedingDoes](docs/Model/PostDeerRequestDeersInnerClassesBreedingDoes.md) +- [PostDeerRequestDeersInnerClassesBucks](docs/Model/PostDeerRequestDeersInnerClassesBucks.md) +- [PostDeerRequestDeersInnerClassesFawn](docs/Model/PostDeerRequestDeersInnerClassesFawn.md) +- [PostDeerRequestDeersInnerClassesOtherDoes](docs/Model/PostDeerRequestDeersInnerClassesOtherDoes.md) +- [PostDeerRequestDeersInnerClassesTradeBucks](docs/Model/PostDeerRequestDeersInnerClassesTradeBucks.md) +- [PostDeerRequestDeersInnerClassesTradeDoes](docs/Model/PostDeerRequestDeersInnerClassesTradeDoes.md) +- [PostDeerRequestDeersInnerClassesTradeFawn](docs/Model/PostDeerRequestDeersInnerClassesTradeFawn.md) +- [PostDeerRequestDeersInnerClassesTradeOtherDoes](docs/Model/PostDeerRequestDeersInnerClassesTradeOtherDoes.md) +- [PostDeerRequestDeersInnerDoesFawning](docs/Model/PostDeerRequestDeersInnerDoesFawning.md) +- [PostDeerRequestDeersInnerSeasonalFawning](docs/Model/PostDeerRequestDeersInnerSeasonalFawning.md) +- [PostDeerRequestVegetationInner](docs/Model/PostDeerRequestVegetationInner.md) +- [PostFeedlot200Response](docs/Model/PostFeedlot200Response.md) +- [PostFeedlot200ResponseIntermediateInner](docs/Model/PostFeedlot200ResponseIntermediateInner.md) +- [PostFeedlot200ResponseIntermediateInnerIntensities](docs/Model/PostFeedlot200ResponseIntermediateInnerIntensities.md) +- [PostFeedlot200ResponseIntermediateInnerNet](docs/Model/PostFeedlot200ResponseIntermediateInnerNet.md) +- [PostFeedlot200ResponseScope1](docs/Model/PostFeedlot200ResponseScope1.md) +- [PostFeedlot200ResponseScope3](docs/Model/PostFeedlot200ResponseScope3.md) +- [PostFeedlotRequest](docs/Model/PostFeedlotRequest.md) +- [PostFeedlotRequestFeedlotsInner](docs/Model/PostFeedlotRequestFeedlotsInner.md) +- [PostFeedlotRequestFeedlotsInnerGroupsInner](docs/Model/PostFeedlotRequestFeedlotsInnerGroupsInner.md) +- [PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner](docs/Model/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.md) +- [PostFeedlotRequestFeedlotsInnerPurchases](docs/Model/PostFeedlotRequestFeedlotsInnerPurchases.md) +- [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner](docs/Model/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.md) +- [PostFeedlotRequestFeedlotsInnerSales](docs/Model/PostFeedlotRequestFeedlotsInnerSales.md) +- [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner](docs/Model/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.md) +- [PostFeedlotRequestVegetationInner](docs/Model/PostFeedlotRequestVegetationInner.md) +- [PostGoat200Response](docs/Model/PostGoat200Response.md) +- [PostGoat200ResponseIntensities](docs/Model/PostGoat200ResponseIntensities.md) +- [PostGoat200ResponseIntermediateInner](docs/Model/PostGoat200ResponseIntermediateInner.md) +- [PostGoat200ResponseNet](docs/Model/PostGoat200ResponseNet.md) +- [PostGoatRequest](docs/Model/PostGoatRequest.md) +- [PostGoatRequestGoatsInner](docs/Model/PostGoatRequestGoatsInner.md) +- [PostGoatRequestGoatsInnerClasses](docs/Model/PostGoatRequestGoatsInnerClasses.md) +- [PostGoatRequestGoatsInnerClassesBreedingDoesNannies](docs/Model/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.md) +- [PostGoatRequestGoatsInnerClassesBucksBilly](docs/Model/PostGoatRequestGoatsInnerClassesBucksBilly.md) +- [PostGoatRequestGoatsInnerClassesKids](docs/Model/PostGoatRequestGoatsInnerClassesKids.md) +- [PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies](docs/Model/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.md) +- [PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales](docs/Model/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.md) +- [PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies](docs/Model/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.md) +- [PostGoatRequestGoatsInnerClassesTradeBucks](docs/Model/PostGoatRequestGoatsInnerClassesTradeBucks.md) +- [PostGoatRequestGoatsInnerClassesTradeDoes](docs/Model/PostGoatRequestGoatsInnerClassesTradeDoes.md) +- [PostGoatRequestGoatsInnerClassesTradeKids](docs/Model/PostGoatRequestGoatsInnerClassesTradeKids.md) +- [PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies](docs/Model/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.md) +- [PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales](docs/Model/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.md) +- [PostGoatRequestGoatsInnerClassesTradeWethers](docs/Model/PostGoatRequestGoatsInnerClassesTradeWethers.md) +- [PostGoatRequestGoatsInnerClassesWethers](docs/Model/PostGoatRequestGoatsInnerClassesWethers.md) +- [PostGoatRequestVegetationInner](docs/Model/PostGoatRequestVegetationInner.md) +- [PostGrains200Response](docs/Model/PostGrains200Response.md) +- [PostGrains200ResponseIntermediateInner](docs/Model/PostGrains200ResponseIntermediateInner.md) +- [PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration](docs/Model/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.md) +- [PostGrainsRequest](docs/Model/PostGrainsRequest.md) +- [PostGrainsRequestCropsInner](docs/Model/PostGrainsRequestCropsInner.md) +- [PostHorticulture200Response](docs/Model/PostHorticulture200Response.md) +- [PostHorticulture200ResponseIntermediateInner](docs/Model/PostHorticulture200ResponseIntermediateInner.md) +- [PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration](docs/Model/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.md) +- [PostHorticulture200ResponseScope1](docs/Model/PostHorticulture200ResponseScope1.md) +- [PostHorticultureRequest](docs/Model/PostHorticultureRequest.md) +- [PostHorticultureRequestCropsInner](docs/Model/PostHorticultureRequestCropsInner.md) +- [PostHorticultureRequestCropsInnerRefrigerantsInner](docs/Model/PostHorticultureRequestCropsInnerRefrigerantsInner.md) +- [PostPork200Response](docs/Model/PostPork200Response.md) +- [PostPork200ResponseIntensities](docs/Model/PostPork200ResponseIntensities.md) +- [PostPork200ResponseIntermediateInner](docs/Model/PostPork200ResponseIntermediateInner.md) +- [PostPork200ResponseNet](docs/Model/PostPork200ResponseNet.md) +- [PostPork200ResponseScope1](docs/Model/PostPork200ResponseScope1.md) +- [PostPork200ResponseScope3](docs/Model/PostPork200ResponseScope3.md) +- [PostPorkRequest](docs/Model/PostPorkRequest.md) +- [PostPorkRequestPorkInner](docs/Model/PostPorkRequestPorkInner.md) +- [PostPorkRequestPorkInnerClasses](docs/Model/PostPorkRequestPorkInnerClasses.md) +- [PostPorkRequestPorkInnerClassesBoars](docs/Model/PostPorkRequestPorkInnerClassesBoars.md) +- [PostPorkRequestPorkInnerClassesGilts](docs/Model/PostPorkRequestPorkInnerClassesGilts.md) +- [PostPorkRequestPorkInnerClassesGrowers](docs/Model/PostPorkRequestPorkInnerClassesGrowers.md) +- [PostPorkRequestPorkInnerClassesSlaughterPigs](docs/Model/PostPorkRequestPorkInnerClassesSlaughterPigs.md) +- [PostPorkRequestPorkInnerClassesSows](docs/Model/PostPorkRequestPorkInnerClassesSows.md) +- [PostPorkRequestPorkInnerClassesSowsManure](docs/Model/PostPorkRequestPorkInnerClassesSowsManure.md) +- [PostPorkRequestPorkInnerClassesSowsManureSpring](docs/Model/PostPorkRequestPorkInnerClassesSowsManureSpring.md) +- [PostPorkRequestPorkInnerClassesSuckers](docs/Model/PostPorkRequestPorkInnerClassesSuckers.md) +- [PostPorkRequestPorkInnerClassesWeaners](docs/Model/PostPorkRequestPorkInnerClassesWeaners.md) +- [PostPorkRequestPorkInnerFeedProductsInner](docs/Model/PostPorkRequestPorkInnerFeedProductsInner.md) +- [PostPorkRequestPorkInnerFeedProductsInnerIngredients](docs/Model/PostPorkRequestPorkInnerFeedProductsInnerIngredients.md) +- [PostPorkRequestVegetationInner](docs/Model/PostPorkRequestVegetationInner.md) +- [PostPoultry200Response](docs/Model/PostPoultry200Response.md) +- [PostPoultry200ResponseIntensities](docs/Model/PostPoultry200ResponseIntensities.md) +- [PostPoultry200ResponseIntermediateBroilersInner](docs/Model/PostPoultry200ResponseIntermediateBroilersInner.md) +- [PostPoultry200ResponseIntermediateBroilersInnerIntensities](docs/Model/PostPoultry200ResponseIntermediateBroilersInnerIntensities.md) +- [PostPoultry200ResponseIntermediateLayersInner](docs/Model/PostPoultry200ResponseIntermediateLayersInner.md) +- [PostPoultry200ResponseIntermediateLayersInnerIntensities](docs/Model/PostPoultry200ResponseIntermediateLayersInnerIntensities.md) +- [PostPoultry200ResponseNet](docs/Model/PostPoultry200ResponseNet.md) +- [PostPoultry200ResponseScope1](docs/Model/PostPoultry200ResponseScope1.md) +- [PostPoultry200ResponseScope3](docs/Model/PostPoultry200ResponseScope3.md) +- [PostPoultryRequest](docs/Model/PostPoultryRequest.md) +- [PostPoultryRequestBroilersInner](docs/Model/PostPoultryRequestBroilersInner.md) +- [PostPoultryRequestBroilersInnerGroupsInner](docs/Model/PostPoultryRequestBroilersInnerGroupsInner.md) +- [PostPoultryRequestBroilersInnerGroupsInnerFeedInner](docs/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.md) +- [PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients](docs/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.md) +- [PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers](docs/Model/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.md) +- [PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases](docs/Model/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.md) +- [PostPoultryRequestBroilersInnerMeatChickenLayersPurchases](docs/Model/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.md) +- [PostPoultryRequestBroilersInnerMeatOtherPurchases](docs/Model/PostPoultryRequestBroilersInnerMeatOtherPurchases.md) +- [PostPoultryRequestBroilersInnerSalesInner](docs/Model/PostPoultryRequestBroilersInnerSalesInner.md) +- [PostPoultryRequestLayersInner](docs/Model/PostPoultryRequestLayersInner.md) +- [PostPoultryRequestLayersInnerLayers](docs/Model/PostPoultryRequestLayersInnerLayers.md) +- [PostPoultryRequestLayersInnerLayersEggSale](docs/Model/PostPoultryRequestLayersInnerLayersEggSale.md) +- [PostPoultryRequestLayersInnerLayersPurchases](docs/Model/PostPoultryRequestLayersInnerLayersPurchases.md) +- [PostPoultryRequestLayersInnerMeatChickenLayers](docs/Model/PostPoultryRequestLayersInnerMeatChickenLayers.md) +- [PostPoultryRequestLayersInnerMeatChickenLayersEggSale](docs/Model/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.md) +- [PostPoultryRequestVegetationInner](docs/Model/PostPoultryRequestVegetationInner.md) +- [PostProcessing200Response](docs/Model/PostProcessing200Response.md) +- [PostProcessing200ResponseIntensitiesInner](docs/Model/PostProcessing200ResponseIntensitiesInner.md) +- [PostProcessing200ResponseIntermediateInner](docs/Model/PostProcessing200ResponseIntermediateInner.md) +- [PostProcessing200ResponseNet](docs/Model/PostProcessing200ResponseNet.md) +- [PostProcessing200ResponseScope1](docs/Model/PostProcessing200ResponseScope1.md) +- [PostProcessing200ResponseScope3](docs/Model/PostProcessing200ResponseScope3.md) +- [PostProcessingRequest](docs/Model/PostProcessingRequest.md) +- [PostProcessingRequestProductsInner](docs/Model/PostProcessingRequestProductsInner.md) +- [PostProcessingRequestProductsInnerProduct](docs/Model/PostProcessingRequestProductsInnerProduct.md) +- [PostRice200Response](docs/Model/PostRice200Response.md) +- [PostRice200ResponseIntensities](docs/Model/PostRice200ResponseIntensities.md) +- [PostRice200ResponseIntermediateInner](docs/Model/PostRice200ResponseIntermediateInner.md) +- [PostRice200ResponseIntermediateInnerIntensities](docs/Model/PostRice200ResponseIntermediateInnerIntensities.md) +- [PostRice200ResponseScope1](docs/Model/PostRice200ResponseScope1.md) +- [PostRiceRequest](docs/Model/PostRiceRequest.md) +- [PostRiceRequestCropsInner](docs/Model/PostRiceRequestCropsInner.md) +- [PostSheep200Response](docs/Model/PostSheep200Response.md) +- [PostSheep200ResponseIntermediateInner](docs/Model/PostSheep200ResponseIntermediateInner.md) +- [PostSheep200ResponseIntermediateInnerIntensities](docs/Model/PostSheep200ResponseIntermediateInnerIntensities.md) +- [PostSheep200ResponseNet](docs/Model/PostSheep200ResponseNet.md) +- [PostSheepRequest](docs/Model/PostSheepRequest.md) +- [PostSheepRequestSheepInner](docs/Model/PostSheepRequestSheepInner.md) +- [PostSheepRequestSheepInnerClasses](docs/Model/PostSheepRequestSheepInnerClasses.md) +- [PostSheepRequestSheepInnerClassesRams](docs/Model/PostSheepRequestSheepInnerClassesRams.md) +- [PostSheepRequestSheepInnerClassesRamsAutumn](docs/Model/PostSheepRequestSheepInnerClassesRamsAutumn.md) +- [PostSheepRequestSheepInnerClassesTradeEwes](docs/Model/PostSheepRequestSheepInnerClassesTradeEwes.md) +- [PostSheepRequestSheepInnerClassesTradeLambsAndHoggets](docs/Model/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.md) +- [PostSheepRequestSheepInnerEwesLambing](docs/Model/PostSheepRequestSheepInnerEwesLambing.md) +- [PostSheepRequestSheepInnerSeasonalLambing](docs/Model/PostSheepRequestSheepInnerSeasonalLambing.md) +- [PostSheepRequestVegetationInner](docs/Model/PostSheepRequestVegetationInner.md) +- [PostSheepbeef200Response](docs/Model/PostSheepbeef200Response.md) +- [PostSheepbeef200ResponseIntensities](docs/Model/PostSheepbeef200ResponseIntensities.md) +- [PostSheepbeef200ResponseIntermediate](docs/Model/PostSheepbeef200ResponseIntermediate.md) +- [PostSheepbeef200ResponseIntermediateBeef](docs/Model/PostSheepbeef200ResponseIntermediateBeef.md) +- [PostSheepbeef200ResponseIntermediateSheep](docs/Model/PostSheepbeef200ResponseIntermediateSheep.md) +- [PostSheepbeef200ResponseNet](docs/Model/PostSheepbeef200ResponseNet.md) +- [PostSheepbeefRequest](docs/Model/PostSheepbeefRequest.md) +- [PostSheepbeefRequestVegetationInner](docs/Model/PostSheepbeefRequestVegetationInner.md) +- [PostSugar200Response](docs/Model/PostSugar200Response.md) +- [PostSugar200ResponseIntermediateInner](docs/Model/PostSugar200ResponseIntermediateInner.md) +- [PostSugar200ResponseIntermediateInnerIntensities](docs/Model/PostSugar200ResponseIntermediateInnerIntensities.md) +- [PostSugarRequest](docs/Model/PostSugarRequest.md) +- [PostSugarRequestCropsInner](docs/Model/PostSugarRequestCropsInner.md) +- [PostVineyard200Response](docs/Model/PostVineyard200Response.md) +- [PostVineyard200ResponseIntermediateInner](docs/Model/PostVineyard200ResponseIntermediateInner.md) +- [PostVineyard200ResponseIntermediateInnerIntensities](docs/Model/PostVineyard200ResponseIntermediateInnerIntensities.md) +- [PostVineyard200ResponseNet](docs/Model/PostVineyard200ResponseNet.md) +- [PostVineyard200ResponseScope1](docs/Model/PostVineyard200ResponseScope1.md) +- [PostVineyard200ResponseScope3](docs/Model/PostVineyard200ResponseScope3.md) +- [PostVineyardRequest](docs/Model/PostVineyardRequest.md) +- [PostVineyardRequestVegetationInner](docs/Model/PostVineyardRequestVegetationInner.md) +- [PostVineyardRequestVineyardsInner](docs/Model/PostVineyardRequestVineyardsInner.md) +- [PostWildcatchfishery200Response](docs/Model/PostWildcatchfishery200Response.md) +- [PostWildcatchfishery200ResponseIntensities](docs/Model/PostWildcatchfishery200ResponseIntensities.md) +- [PostWildcatchfishery200ResponseIntermediateInner](docs/Model/PostWildcatchfishery200ResponseIntermediateInner.md) +- [PostWildcatchfishery200ResponseScope1](docs/Model/PostWildcatchfishery200ResponseScope1.md) +- [PostWildcatchfisheryRequest](docs/Model/PostWildcatchfisheryRequest.md) +- [PostWildcatchfisheryRequestEnterprisesInner](docs/Model/PostWildcatchfisheryRequestEnterprisesInner.md) +- [PostWildcatchfisheryRequestEnterprisesInnerBaitInner](docs/Model/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.md) +- [PostWildseafisheries200Response](docs/Model/PostWildseafisheries200Response.md) +- [PostWildseafisheries200ResponseIntermediateInner](docs/Model/PostWildseafisheries200ResponseIntermediateInner.md) +- [PostWildseafisheries200ResponseIntermediateInnerIntensities](docs/Model/PostWildseafisheries200ResponseIntermediateInnerIntensities.md) +- [PostWildseafisheries200ResponseScope1](docs/Model/PostWildseafisheries200ResponseScope1.md) +- [PostWildseafisheries200ResponseScope3](docs/Model/PostWildseafisheries200ResponseScope3.md) +- [PostWildseafisheriesRequest](docs/Model/PostWildseafisheriesRequest.md) +- [PostWildseafisheriesRequestEnterprisesInner](docs/Model/PostWildseafisheriesRequestEnterprisesInner.md) +- [PostWildseafisheriesRequestEnterprisesInnerBaitInner](docs/Model/PostWildseafisheriesRequestEnterprisesInnerBaitInner.md) +- [PostWildseafisheriesRequestEnterprisesInnerCustombaitInner](docs/Model/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.md) +- [PostWildseafisheriesRequestEnterprisesInnerFlightsInner](docs/Model/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.md) +- [PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner](docs/Model/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.md) +- [PostWildseafisheriesRequestEnterprisesInnerTransportsInner](docs/Model/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.md) + +## Authorization +Endpoints do not require authorization. + +## Tests + +To run the tests, use: + +```bash +composer install +vendor/bin/phpunit +``` + +## Author + +contact@aginnovationaustralia.com.au + +## About this package + +This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: `3.0.0` + - Generator version: `7.16.0` +- Build package: `org.openapitools.codegen.languages.PhpClientCodegen` diff --git a/examples/php-api-client/api-client/composer.json b/examples/php-api-client/api-client/composer.json new file mode 100644 index 00000000..afc9ecd4 --- /dev/null +++ b/examples/php-api-client/api-client/composer.json @@ -0,0 +1,38 @@ +{ + "description": "Emissions Calculators for various farming activities", + "keywords": [ + "openapitools", + "openapi-generator", + "openapi", + "php", + "sdk", + "rest", + "api" + ], + "homepage": "https://openapi-generator.tech", + "license": "unlicense", + "authors": [ + { + "name": "OpenAPI", + "homepage": "https://openapi-generator.tech" + } + ], + "require": { + "php": "^8.1", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^1.7 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.0 || ^9.0", + "friendsofphp/php-cs-fixer": "^3.5" + }, + "autoload": { + "psr-4": { "OpenAPI\\Client\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "OpenAPI\\Client\\Test\\" : "test/" } + } +} diff --git a/examples/php-api-client/api-client/composer.lock b/examples/php-api-client/api-client/composer.lock new file mode 100644 index 00000000..df2fce19 --- /dev/null +++ b/examples/php-api-client/api-client/composer.lock @@ -0,0 +1,4940 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "3d156d10b574f52a2dfd9a5ced1e76a6", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "7.10.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^2.3", + "guzzlehttp/psr7": "^2.8", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.10.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2025-08-23T22:36:01+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "481557b130ef3790cf82b713667b43030dc9c957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", + "reference": "481557b130ef3790cf82b713667b43030dc9c957", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2025-08-22T14:34:08+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "21dc724a0583619cd1652f673303492272778051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051", + "reference": "21dc724a0583619cd1652f673303492272778051", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.8.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2025-08-23T21:21:41+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + } + ], + "packages-dev": [ + { + "name": "clue/ndjson-react", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\React\\NDJson\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", + "keywords": [ + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" + ], + "support": { + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-12-23T10:58:28+00:00" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-05-06T16:37:16+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, + { + "name": "evenement/evenement", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Evenement\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" + }, + "time": "2023-08-08T05:53:35+00:00" + }, + { + "name": "fidry/cpu-core-counter", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2025-08-14T07:29:31+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.89.1", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "f34967da2866ace090a2b447de1f357356474573" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/f34967da2866ace090a2b447de1f357356474573", + "reference": "f34967da2866ace090a2b447de1f357356474573", + "shasum": "" + }, + "require": { + "clue/ndjson-react": "^1.3", + "composer/semver": "^3.4", + "composer/xdebug-handler": "^3.0.5", + "ext-filter": "*", + "ext-hash": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "fidry/cpu-core-counter": "^1.3", + "php": "^7.4 || ^8.0", + "react/child-process": "^0.6.6", + "react/event-loop": "^1.5", + "react/socket": "^1.16", + "react/stream": "^1.4", + "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0", + "symfony/console": "^5.4.47 || ^6.4.24 || ^7.0", + "symfony/event-dispatcher": "^5.4.45 || ^6.4.24 || ^7.0", + "symfony/filesystem": "^5.4.45 || ^6.4.24 || ^7.0", + "symfony/finder": "^5.4.45 || ^6.4.24 || ^7.0", + "symfony/options-resolver": "^5.4.45 || ^6.4.24 || ^7.0", + "symfony/polyfill-mbstring": "^1.33", + "symfony/polyfill-php80": "^1.33", + "symfony/polyfill-php81": "^1.33", + "symfony/polyfill-php84": "^1.33", + "symfony/process": "^5.4.47 || ^6.4.24 || ^7.2", + "symfony/stopwatch": "^5.4.45 || ^6.4.24 || ^7.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3.1 || ^2.7", + "infection/infection": "^0.31.0", + "justinrainbow/json-schema": "^6.5", + "keradus/cli-executor": "^2.2", + "mikey179/vfsstream": "^1.6.12", + "php-coveralls/php-coveralls": "^2.8", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6", + "phpunit/phpunit": "^9.6.25 || ^10.5.53 || ^11.5.34", + "symfony/var-dumper": "^5.4.48 || ^6.4.24 || ^7.3.2", + "symfony/yaml": "^5.4.45 || ^6.4.24 || ^7.3.2" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "exclude-from-classmap": [ + "src/Fixer/Internal/*" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.89.1" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2025-10-24T12:05:10+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.6.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "3a454ca033b9e06b63282ce19562e892747449bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", + "reference": "3a454ca033b9e06b63282ce19562e892747449bb", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" + }, + "time": "2025-10-21T19:32:17+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.32", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:23:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.29", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "9ecfec57835a5581bc888ea7e13b51eb55ab9dd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ecfec57835a5581bc888ea7e13b51eb55ab9dd3", + "reference": "9ecfec57835a5581bc888ea7e13b51eb55ab9dd3", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.9", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.8", + "sebastian/global-state": "^5.0.8", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.29" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:29:11+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "react/cache", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/child-process", + "version": "v0.6.6", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159", + "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/socket": "^1.16", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.6" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-01-01T16:37:48+00:00" + }, + { + "name": "react/dns", + "version": "v1.13.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3 || ^2", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.13.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-13T14:18:03+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.5.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-13T13:48:05+00:00" + }, + { + "name": "react/promise", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "23444f53a813a3296c1368bb104793ce8d88f04a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a", + "reference": "23444f53a813a3296c1368bb104793ce8d88f04a", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpstan/phpstan": "1.12.28 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-08-19T18:57:03+00:00" + }, + { + "name": "react/socket", + "version": "v1.16.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.13", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/stream": "^1.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3.3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.16.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-07-26T10:38:09+00:00" + }, + { + "name": "react/stream", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.4.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-11T12:45:25+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "67a2df3a62639eab2cc5906065e9805d4fd5dfc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/67a2df3a62639eab2cc5906065e9805d4fd5dfc5", + "reference": "67a2df3a62639eab2cc5906065e9805d4fd5dfc5", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.9" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:51:50+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "reference": "14c6ba52f95a36c3d27c835d65efc7123c446e8c", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:03:27+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/global-state", + "type": "tidelift" + } + ], + "time": "2025-08-10T07:10:35+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:57:39+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-14T16:00:52+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "symfony/console", + "version": "v7.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/2b9c5fafbac0399a20a2e82429e2bd735dcfb7db", + "reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^7.2" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/dotenv": "<6.4", + "symfony/event-dispatcher": "<6.4", + "symfony/lock": "<6.4", + "symfony/process": "<6.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/var-dumper": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v7.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-09-22T15:31:00+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v7.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191", + "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/error-handler": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v7.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-08-13T11:49:31+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "59eb412e93815df44f05f342958efa9f46b1e586" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586", + "reference": "59eb412e93815df44f05f342958efa9f46b1e586", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v7.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edcbb768a186b5c3f25d0643159a787d3e63b7fd", + "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v7.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-07-07T08:17:47+00:00" + }, + { + "name": "symfony/finder", + "version": "v7.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/2a6614966ba1074fa93dae0bc804227422df4dfe", + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "symfony/filesystem": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v7.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-07-15T13:41:35+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v7.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "0ff2f5c3df08a395232bbc3c2eb7e84912df911d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0ff2f5c3df08a395232bbc3c2eb7e84912df911d", + "reference": "0ff2f5c3df08a395232bbc3c2eb7e84912df911d", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v7.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-08-05T10:16:07+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-27T09:58:17+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "3833d7255cc303546435cb650316bff708a1c75c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-12-23T08:48:59+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-01-02T08:10:11+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php84", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-24T13:30:11+00:00" + }, + { + "name": "symfony/process", + "version": "v7.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/f24f8f316367b30810810d4eb30c543d7003ff3b", + "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v7.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-09-11T10:12:26+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-04-25T09:37:31+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v7.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd", + "reference": "5a49289e2b308214c8b9c2fda4ea454d8b8ad7cd", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/service-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v7.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-02-24T10:49:57+00:00" + }, + { + "name": "symfony/string", + "version": "v7.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "f96476035142921000338bad71e5247fbc138872" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872", + "reference": "f96476035142921000338bad71e5247fbc138872", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/emoji": "^7.1", + "symfony/http-client": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v7.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-09-11T14:36:48+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.1", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/examples/php-api-client/api-client/example.php b/examples/php-api-client/api-client/example.php new file mode 100644 index 00000000..f4946acb --- /dev/null +++ b/examples/php-api-client/api-client/example.php @@ -0,0 +1,143 @@ + 50, + 'liveweight' => 450, + 'liveweight_gain' => 0.5 + ]); + + $summerSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 440, + 'liveweight_gain' => 0.3 + ]); + + $autumnSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 460, + 'liveweight_gain' => 0.4 + ]); + + $winterSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 450, + 'liveweight_gain' => 0.4 + ]); + + // Create cows class (greater than 2 years old) + $cowsGt2 = new PostBeefRequestBeefInnerClassesCowsGt2([ + 'spring' => $springSeason, + 'summer' => $summerSeason, + 'autumn' => $autumnSeason, + 'winter' => $winterSeason, + 'head_sold' => 25, + 'sale_weight' => 500 + ]); + + // Create classes object with cows + $classes = new PostBeefRequestBeefInnerClasses([ + 'cows_gt2' => $cowsGt2 + ]); + + // Create fertiliser object + $fertiliser = new PostBeefRequestBeefInnerFertiliser([ + 'single_superphosphate' => 5.0, + 'pasture_dryland' => 10.0, + 'pasture_irrigated' => 2.0, + 'crops_dryland' => 8.0, + 'crops_irrigated' => 1.0 + ]); + + // Create mineral supplementation object + $mineralSupplementation = new PostBeefRequestBeefInnerMineralSupplementation([ + 'mineral_block' => 2.0, + 'mineral_block_urea' => 0.3, + 'weaner_block' => 1.0, + 'weaner_block_urea' => 0.2, + 'dry_season_mix' => 1.5, + 'dry_season_mix_urea' => 0.25 + ]); + + // Create cows calving object + $cowsCalving = new PostBeefRequestBeefInnerCowsCalving([ + 'spring' => 0.2, + 'summer' => 0.1, + 'autumn' => 0.5, + 'winter' => 0.2 + ]); + + // Create beef inner object + $beefInner = new PostBeefRequestBeefInner([ + 'id' => 'beef_cattle_001', + 'classes' => $classes, + 'limestone' => 10.0, + 'limestone_fraction' => 0.8, + 'fertiliser' => $fertiliser, + 'diesel' => 1000, + 'petrol' => 200, + 'lpg' => 100, + 'mineral_supplementation' => $mineralSupplementation, + 'electricity_source' => 'State Grid', + 'electricity_renewable' => 0.2, + 'electricity_use' => 5000, + 'grain_feed' => 10.0, + 'hay_feed' => 5.0, + 'cottonseed_feed' => 2.0, + 'herbicide' => 50.0, + 'herbicide_other' => 20.0, + 'cows_calving' => $cowsCalving + ]); + + // Create main request object + $request = new PostBeefRequest([ + 'state' => 'qld', + 'north_of_tropic_of_capricorn' => true, + 'rainfall_above600' => true, + 'beef' => [$beefInner], + 'burning' => [], + 'vegetation' => [] + ]); + + // Configure API + $config = Configuration::getDefaultConfiguration(); + $config->setHost('https://emissionscalculator-mtls.staging.aiaapi.com/calculator/3.0.0'); + $config->setCertFile(__DIR__ . '/cert.pem'); + $config->setKeyFile(__DIR__ . '/key.pem'); + + // Initialize API + $api = new GAFApi(new Client(), $config); + + echo "Calling beef API...\n"; + echo "================================\n"; + + // Make the API call + $result = $api->postBeef($request); + + // Print the result + echo "Success! API call completed.\n\n"; + echo "Response:\n"; + print_r($result); + + echo "\n================================\n"; + echo "API call complete!\n"; + +} catch (Exception $e) { + echo "Error: " . $e->getMessage() . "\n"; + echo "File: " . $e->getFile() . "\n"; + echo "Line: " . $e->getLine() . "\n"; +} \ No newline at end of file diff --git a/examples/php-api-client/api-client/git_push.sh b/examples/php-api-client/api-client/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/examples/php-api-client/api-client/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/examples/php-api-client/api-client/lib/Api/GAFApi.php b/examples/php-api-client/api-client/lib/Api/GAFApi.php new file mode 100644 index 00000000..a07d9e6f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Api/GAFApi.php @@ -0,0 +1,5595 @@ + [ + 'application/json', + ], + 'postBeef' => [ + 'application/json', + ], + 'postBuffalo' => [ + 'application/json', + ], + 'postCotton' => [ + 'application/json', + ], + 'postDairy' => [ + 'application/json', + ], + 'postDeer' => [ + 'application/json', + ], + 'postFeedlot' => [ + 'application/json', + ], + 'postGoat' => [ + 'application/json', + ], + 'postGrains' => [ + 'application/json', + ], + 'postHorticulture' => [ + 'application/json', + ], + 'postPork' => [ + 'application/json', + ], + 'postPoultry' => [ + 'application/json', + ], + 'postProcessing' => [ + 'application/json', + ], + 'postRice' => [ + 'application/json', + ], + 'postSheep' => [ + 'application/json', + ], + 'postSheepbeef' => [ + 'application/json', + ], + 'postSugar' => [ + 'application/json', + ], + 'postVineyard' => [ + 'application/json', + ], + 'postWildcatchfishery' => [ + 'application/json', + ], + 'postWildseafisheries' => [ + '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, + int $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 postAquaculture + * + * Perform aquaculture calculation + * + * @param \OpenAPI\Client\Model\PostAquacultureRequest $post_aquaculture_request post_aquaculture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postAquaculture'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostAquaculture200Response + */ + public function postAquaculture($post_aquaculture_request, string $contentType = self::contentTypes['postAquaculture'][0]) + { + list($response) = $this->postAquacultureWithHttpInfo($post_aquaculture_request, $contentType); + return $response; + } + + /** + * Operation postAquacultureWithHttpInfo + * + * Perform aquaculture calculation + * + * @param \OpenAPI\Client\Model\PostAquacultureRequest $post_aquaculture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postAquaculture'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostAquaculture200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postAquacultureWithHttpInfo($post_aquaculture_request, string $contentType = self::contentTypes['postAquaculture'][0]) + { + $request = $this->postAquacultureRequest($post_aquaculture_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostAquaculture200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostAquaculture200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostAquaculture200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postAquacultureAsync + * + * Perform aquaculture calculation + * + * @param \OpenAPI\Client\Model\PostAquacultureRequest $post_aquaculture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postAquaculture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postAquacultureAsync($post_aquaculture_request, string $contentType = self::contentTypes['postAquaculture'][0]) + { + return $this->postAquacultureAsyncWithHttpInfo($post_aquaculture_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postAquacultureAsyncWithHttpInfo + * + * Perform aquaculture calculation + * + * @param \OpenAPI\Client\Model\PostAquacultureRequest $post_aquaculture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postAquaculture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postAquacultureAsyncWithHttpInfo($post_aquaculture_request, string $contentType = self::contentTypes['postAquaculture'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostAquaculture200Response'; + $request = $this->postAquacultureRequest($post_aquaculture_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postAquaculture' + * + * @param \OpenAPI\Client\Model\PostAquacultureRequest $post_aquaculture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postAquaculture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postAquacultureRequest($post_aquaculture_request, string $contentType = self::contentTypes['postAquaculture'][0]) + { + + // verify the required parameter 'post_aquaculture_request' is set + if ($post_aquaculture_request === null || (is_array($post_aquaculture_request) && count($post_aquaculture_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_aquaculture_request when calling postAquaculture' + ); + } + + + $resourcePath = '/aquaculture'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_aquaculture_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_aquaculture_request)); + } else { + $httpBody = $post_aquaculture_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postBeef + * + * Perform beef calculation + * + * @param \OpenAPI\Client\Model\PostBeefRequest $post_beef_request post_beef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBeef'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostBeef200Response + */ + public function postBeef($post_beef_request, string $contentType = self::contentTypes['postBeef'][0]) + { + list($response) = $this->postBeefWithHttpInfo($post_beef_request, $contentType); + return $response; + } + + /** + * Operation postBeefWithHttpInfo + * + * Perform beef calculation + * + * @param \OpenAPI\Client\Model\PostBeefRequest $post_beef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBeef'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostBeef200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postBeefWithHttpInfo($post_beef_request, string $contentType = self::contentTypes['postBeef'][0]) + { + $request = $this->postBeefRequest($post_beef_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostBeef200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostBeef200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostBeef200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postBeefAsync + * + * Perform beef calculation + * + * @param \OpenAPI\Client\Model\PostBeefRequest $post_beef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postBeefAsync($post_beef_request, string $contentType = self::contentTypes['postBeef'][0]) + { + return $this->postBeefAsyncWithHttpInfo($post_beef_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postBeefAsyncWithHttpInfo + * + * Perform beef calculation + * + * @param \OpenAPI\Client\Model\PostBeefRequest $post_beef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postBeefAsyncWithHttpInfo($post_beef_request, string $contentType = self::contentTypes['postBeef'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostBeef200Response'; + $request = $this->postBeefRequest($post_beef_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postBeef' + * + * @param \OpenAPI\Client\Model\PostBeefRequest $post_beef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postBeefRequest($post_beef_request, string $contentType = self::contentTypes['postBeef'][0]) + { + + // verify the required parameter 'post_beef_request' is set + if ($post_beef_request === null || (is_array($post_beef_request) && count($post_beef_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_beef_request when calling postBeef' + ); + } + + + $resourcePath = '/beef'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_beef_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_beef_request)); + } else { + $httpBody = $post_beef_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postBuffalo + * + * Perform buffalo calculation + * + * @param \OpenAPI\Client\Model\PostBuffaloRequest $post_buffalo_request post_buffalo_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBuffalo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostBuffalo200Response + */ + public function postBuffalo($post_buffalo_request, string $contentType = self::contentTypes['postBuffalo'][0]) + { + list($response) = $this->postBuffaloWithHttpInfo($post_buffalo_request, $contentType); + return $response; + } + + /** + * Operation postBuffaloWithHttpInfo + * + * Perform buffalo calculation + * + * @param \OpenAPI\Client\Model\PostBuffaloRequest $post_buffalo_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBuffalo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostBuffalo200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postBuffaloWithHttpInfo($post_buffalo_request, string $contentType = self::contentTypes['postBuffalo'][0]) + { + $request = $this->postBuffaloRequest($post_buffalo_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostBuffalo200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostBuffalo200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostBuffalo200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postBuffaloAsync + * + * Perform buffalo calculation + * + * @param \OpenAPI\Client\Model\PostBuffaloRequest $post_buffalo_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBuffalo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postBuffaloAsync($post_buffalo_request, string $contentType = self::contentTypes['postBuffalo'][0]) + { + return $this->postBuffaloAsyncWithHttpInfo($post_buffalo_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postBuffaloAsyncWithHttpInfo + * + * Perform buffalo calculation + * + * @param \OpenAPI\Client\Model\PostBuffaloRequest $post_buffalo_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBuffalo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postBuffaloAsyncWithHttpInfo($post_buffalo_request, string $contentType = self::contentTypes['postBuffalo'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostBuffalo200Response'; + $request = $this->postBuffaloRequest($post_buffalo_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postBuffalo' + * + * @param \OpenAPI\Client\Model\PostBuffaloRequest $post_buffalo_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postBuffalo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postBuffaloRequest($post_buffalo_request, string $contentType = self::contentTypes['postBuffalo'][0]) + { + + // verify the required parameter 'post_buffalo_request' is set + if ($post_buffalo_request === null || (is_array($post_buffalo_request) && count($post_buffalo_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_buffalo_request when calling postBuffalo' + ); + } + + + $resourcePath = '/buffalo'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_buffalo_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_buffalo_request)); + } else { + $httpBody = $post_buffalo_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postCotton + * + * Perform cotton calculation + * + * @param \OpenAPI\Client\Model\PostCottonRequest $post_cotton_request post_cotton_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postCotton'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostCotton200Response + */ + public function postCotton($post_cotton_request, string $contentType = self::contentTypes['postCotton'][0]) + { + list($response) = $this->postCottonWithHttpInfo($post_cotton_request, $contentType); + return $response; + } + + /** + * Operation postCottonWithHttpInfo + * + * Perform cotton calculation + * + * @param \OpenAPI\Client\Model\PostCottonRequest $post_cotton_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postCotton'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostCotton200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postCottonWithHttpInfo($post_cotton_request, string $contentType = self::contentTypes['postCotton'][0]) + { + $request = $this->postCottonRequest($post_cotton_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostCotton200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostCotton200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostCotton200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postCottonAsync + * + * Perform cotton calculation + * + * @param \OpenAPI\Client\Model\PostCottonRequest $post_cotton_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postCotton'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postCottonAsync($post_cotton_request, string $contentType = self::contentTypes['postCotton'][0]) + { + return $this->postCottonAsyncWithHttpInfo($post_cotton_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postCottonAsyncWithHttpInfo + * + * Perform cotton calculation + * + * @param \OpenAPI\Client\Model\PostCottonRequest $post_cotton_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postCotton'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postCottonAsyncWithHttpInfo($post_cotton_request, string $contentType = self::contentTypes['postCotton'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostCotton200Response'; + $request = $this->postCottonRequest($post_cotton_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postCotton' + * + * @param \OpenAPI\Client\Model\PostCottonRequest $post_cotton_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postCotton'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postCottonRequest($post_cotton_request, string $contentType = self::contentTypes['postCotton'][0]) + { + + // verify the required parameter 'post_cotton_request' is set + if ($post_cotton_request === null || (is_array($post_cotton_request) && count($post_cotton_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_cotton_request when calling postCotton' + ); + } + + + $resourcePath = '/cotton'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_cotton_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_cotton_request)); + } else { + $httpBody = $post_cotton_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postDairy + * + * Perform dairy calculation + * + * @param \OpenAPI\Client\Model\PostDairyRequest $post_dairy_request post_dairy_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDairy'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostDairy200Response + */ + public function postDairy($post_dairy_request, string $contentType = self::contentTypes['postDairy'][0]) + { + list($response) = $this->postDairyWithHttpInfo($post_dairy_request, $contentType); + return $response; + } + + /** + * Operation postDairyWithHttpInfo + * + * Perform dairy calculation + * + * @param \OpenAPI\Client\Model\PostDairyRequest $post_dairy_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDairy'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostDairy200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postDairyWithHttpInfo($post_dairy_request, string $contentType = self::contentTypes['postDairy'][0]) + { + $request = $this->postDairyRequest($post_dairy_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostDairy200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostDairy200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostDairy200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postDairyAsync + * + * Perform dairy calculation + * + * @param \OpenAPI\Client\Model\PostDairyRequest $post_dairy_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDairy'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postDairyAsync($post_dairy_request, string $contentType = self::contentTypes['postDairy'][0]) + { + return $this->postDairyAsyncWithHttpInfo($post_dairy_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postDairyAsyncWithHttpInfo + * + * Perform dairy calculation + * + * @param \OpenAPI\Client\Model\PostDairyRequest $post_dairy_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDairy'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postDairyAsyncWithHttpInfo($post_dairy_request, string $contentType = self::contentTypes['postDairy'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostDairy200Response'; + $request = $this->postDairyRequest($post_dairy_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postDairy' + * + * @param \OpenAPI\Client\Model\PostDairyRequest $post_dairy_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDairy'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postDairyRequest($post_dairy_request, string $contentType = self::contentTypes['postDairy'][0]) + { + + // verify the required parameter 'post_dairy_request' is set + if ($post_dairy_request === null || (is_array($post_dairy_request) && count($post_dairy_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_dairy_request when calling postDairy' + ); + } + + + $resourcePath = '/dairy'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_dairy_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_dairy_request)); + } else { + $httpBody = $post_dairy_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postDeer + * + * Perform deer calculation + * + * @param \OpenAPI\Client\Model\PostDeerRequest $post_deer_request post_deer_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDeer'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostDeer200Response + */ + public function postDeer($post_deer_request, string $contentType = self::contentTypes['postDeer'][0]) + { + list($response) = $this->postDeerWithHttpInfo($post_deer_request, $contentType); + return $response; + } + + /** + * Operation postDeerWithHttpInfo + * + * Perform deer calculation + * + * @param \OpenAPI\Client\Model\PostDeerRequest $post_deer_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDeer'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostDeer200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postDeerWithHttpInfo($post_deer_request, string $contentType = self::contentTypes['postDeer'][0]) + { + $request = $this->postDeerRequest($post_deer_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostDeer200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostDeer200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostDeer200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postDeerAsync + * + * Perform deer calculation + * + * @param \OpenAPI\Client\Model\PostDeerRequest $post_deer_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDeer'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postDeerAsync($post_deer_request, string $contentType = self::contentTypes['postDeer'][0]) + { + return $this->postDeerAsyncWithHttpInfo($post_deer_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postDeerAsyncWithHttpInfo + * + * Perform deer calculation + * + * @param \OpenAPI\Client\Model\PostDeerRequest $post_deer_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDeer'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postDeerAsyncWithHttpInfo($post_deer_request, string $contentType = self::contentTypes['postDeer'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostDeer200Response'; + $request = $this->postDeerRequest($post_deer_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postDeer' + * + * @param \OpenAPI\Client\Model\PostDeerRequest $post_deer_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postDeer'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postDeerRequest($post_deer_request, string $contentType = self::contentTypes['postDeer'][0]) + { + + // verify the required parameter 'post_deer_request' is set + if ($post_deer_request === null || (is_array($post_deer_request) && count($post_deer_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_deer_request when calling postDeer' + ); + } + + + $resourcePath = '/deer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_deer_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_deer_request)); + } else { + $httpBody = $post_deer_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postFeedlot + * + * Perform feedlot calculation + * + * @param \OpenAPI\Client\Model\PostFeedlotRequest $post_feedlot_request post_feedlot_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postFeedlot'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostFeedlot200Response + */ + public function postFeedlot($post_feedlot_request, string $contentType = self::contentTypes['postFeedlot'][0]) + { + list($response) = $this->postFeedlotWithHttpInfo($post_feedlot_request, $contentType); + return $response; + } + + /** + * Operation postFeedlotWithHttpInfo + * + * Perform feedlot calculation + * + * @param \OpenAPI\Client\Model\PostFeedlotRequest $post_feedlot_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postFeedlot'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostFeedlot200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postFeedlotWithHttpInfo($post_feedlot_request, string $contentType = self::contentTypes['postFeedlot'][0]) + { + $request = $this->postFeedlotRequest($post_feedlot_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostFeedlot200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostFeedlot200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostFeedlot200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postFeedlotAsync + * + * Perform feedlot calculation + * + * @param \OpenAPI\Client\Model\PostFeedlotRequest $post_feedlot_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postFeedlot'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postFeedlotAsync($post_feedlot_request, string $contentType = self::contentTypes['postFeedlot'][0]) + { + return $this->postFeedlotAsyncWithHttpInfo($post_feedlot_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postFeedlotAsyncWithHttpInfo + * + * Perform feedlot calculation + * + * @param \OpenAPI\Client\Model\PostFeedlotRequest $post_feedlot_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postFeedlot'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postFeedlotAsyncWithHttpInfo($post_feedlot_request, string $contentType = self::contentTypes['postFeedlot'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostFeedlot200Response'; + $request = $this->postFeedlotRequest($post_feedlot_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postFeedlot' + * + * @param \OpenAPI\Client\Model\PostFeedlotRequest $post_feedlot_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postFeedlot'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postFeedlotRequest($post_feedlot_request, string $contentType = self::contentTypes['postFeedlot'][0]) + { + + // verify the required parameter 'post_feedlot_request' is set + if ($post_feedlot_request === null || (is_array($post_feedlot_request) && count($post_feedlot_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_feedlot_request when calling postFeedlot' + ); + } + + + $resourcePath = '/feedlot'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_feedlot_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_feedlot_request)); + } else { + $httpBody = $post_feedlot_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postGoat + * + * Perform goat calculation + * + * @param \OpenAPI\Client\Model\PostGoatRequest $post_goat_request post_goat_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGoat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostGoat200Response + */ + public function postGoat($post_goat_request, string $contentType = self::contentTypes['postGoat'][0]) + { + list($response) = $this->postGoatWithHttpInfo($post_goat_request, $contentType); + return $response; + } + + /** + * Operation postGoatWithHttpInfo + * + * Perform goat calculation + * + * @param \OpenAPI\Client\Model\PostGoatRequest $post_goat_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGoat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostGoat200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postGoatWithHttpInfo($post_goat_request, string $contentType = self::contentTypes['postGoat'][0]) + { + $request = $this->postGoatRequest($post_goat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostGoat200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostGoat200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostGoat200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postGoatAsync + * + * Perform goat calculation + * + * @param \OpenAPI\Client\Model\PostGoatRequest $post_goat_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGoat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postGoatAsync($post_goat_request, string $contentType = self::contentTypes['postGoat'][0]) + { + return $this->postGoatAsyncWithHttpInfo($post_goat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postGoatAsyncWithHttpInfo + * + * Perform goat calculation + * + * @param \OpenAPI\Client\Model\PostGoatRequest $post_goat_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGoat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postGoatAsyncWithHttpInfo($post_goat_request, string $contentType = self::contentTypes['postGoat'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostGoat200Response'; + $request = $this->postGoatRequest($post_goat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postGoat' + * + * @param \OpenAPI\Client\Model\PostGoatRequest $post_goat_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGoat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postGoatRequest($post_goat_request, string $contentType = self::contentTypes['postGoat'][0]) + { + + // verify the required parameter 'post_goat_request' is set + if ($post_goat_request === null || (is_array($post_goat_request) && count($post_goat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_goat_request when calling postGoat' + ); + } + + + $resourcePath = '/goat'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_goat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_goat_request)); + } else { + $httpBody = $post_goat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postGrains + * + * Perform grains calculation + * + * @param \OpenAPI\Client\Model\PostGrainsRequest $post_grains_request post_grains_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGrains'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostGrains200Response + */ + public function postGrains($post_grains_request, string $contentType = self::contentTypes['postGrains'][0]) + { + list($response) = $this->postGrainsWithHttpInfo($post_grains_request, $contentType); + return $response; + } + + /** + * Operation postGrainsWithHttpInfo + * + * Perform grains calculation + * + * @param \OpenAPI\Client\Model\PostGrainsRequest $post_grains_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGrains'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostGrains200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postGrainsWithHttpInfo($post_grains_request, string $contentType = self::contentTypes['postGrains'][0]) + { + $request = $this->postGrainsRequest($post_grains_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostGrains200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostGrains200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostGrains200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postGrainsAsync + * + * Perform grains calculation + * + * @param \OpenAPI\Client\Model\PostGrainsRequest $post_grains_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGrains'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postGrainsAsync($post_grains_request, string $contentType = self::contentTypes['postGrains'][0]) + { + return $this->postGrainsAsyncWithHttpInfo($post_grains_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postGrainsAsyncWithHttpInfo + * + * Perform grains calculation + * + * @param \OpenAPI\Client\Model\PostGrainsRequest $post_grains_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGrains'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postGrainsAsyncWithHttpInfo($post_grains_request, string $contentType = self::contentTypes['postGrains'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostGrains200Response'; + $request = $this->postGrainsRequest($post_grains_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postGrains' + * + * @param \OpenAPI\Client\Model\PostGrainsRequest $post_grains_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postGrains'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postGrainsRequest($post_grains_request, string $contentType = self::contentTypes['postGrains'][0]) + { + + // verify the required parameter 'post_grains_request' is set + if ($post_grains_request === null || (is_array($post_grains_request) && count($post_grains_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_grains_request when calling postGrains' + ); + } + + + $resourcePath = '/grains'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_grains_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_grains_request)); + } else { + $httpBody = $post_grains_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postHorticulture + * + * Perform horticulture calculation + * + * @param \OpenAPI\Client\Model\PostHorticultureRequest $post_horticulture_request post_horticulture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postHorticulture'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostHorticulture200Response + */ + public function postHorticulture($post_horticulture_request, string $contentType = self::contentTypes['postHorticulture'][0]) + { + list($response) = $this->postHorticultureWithHttpInfo($post_horticulture_request, $contentType); + return $response; + } + + /** + * Operation postHorticultureWithHttpInfo + * + * Perform horticulture calculation + * + * @param \OpenAPI\Client\Model\PostHorticultureRequest $post_horticulture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postHorticulture'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostHorticulture200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postHorticultureWithHttpInfo($post_horticulture_request, string $contentType = self::contentTypes['postHorticulture'][0]) + { + $request = $this->postHorticultureRequest($post_horticulture_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostHorticulture200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostHorticulture200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostHorticulture200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postHorticultureAsync + * + * Perform horticulture calculation + * + * @param \OpenAPI\Client\Model\PostHorticultureRequest $post_horticulture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postHorticulture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postHorticultureAsync($post_horticulture_request, string $contentType = self::contentTypes['postHorticulture'][0]) + { + return $this->postHorticultureAsyncWithHttpInfo($post_horticulture_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postHorticultureAsyncWithHttpInfo + * + * Perform horticulture calculation + * + * @param \OpenAPI\Client\Model\PostHorticultureRequest $post_horticulture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postHorticulture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postHorticultureAsyncWithHttpInfo($post_horticulture_request, string $contentType = self::contentTypes['postHorticulture'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostHorticulture200Response'; + $request = $this->postHorticultureRequest($post_horticulture_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postHorticulture' + * + * @param \OpenAPI\Client\Model\PostHorticultureRequest $post_horticulture_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postHorticulture'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postHorticultureRequest($post_horticulture_request, string $contentType = self::contentTypes['postHorticulture'][0]) + { + + // verify the required parameter 'post_horticulture_request' is set + if ($post_horticulture_request === null || (is_array($post_horticulture_request) && count($post_horticulture_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_horticulture_request when calling postHorticulture' + ); + } + + + $resourcePath = '/horticulture'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_horticulture_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_horticulture_request)); + } else { + $httpBody = $post_horticulture_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postPork + * + * Perform pork calculation + * + * @param \OpenAPI\Client\Model\PostPorkRequest $post_pork_request post_pork_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPork'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostPork200Response + */ + public function postPork($post_pork_request, string $contentType = self::contentTypes['postPork'][0]) + { + list($response) = $this->postPorkWithHttpInfo($post_pork_request, $contentType); + return $response; + } + + /** + * Operation postPorkWithHttpInfo + * + * Perform pork calculation + * + * @param \OpenAPI\Client\Model\PostPorkRequest $post_pork_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPork'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostPork200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postPorkWithHttpInfo($post_pork_request, string $contentType = self::contentTypes['postPork'][0]) + { + $request = $this->postPorkRequest($post_pork_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostPork200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostPork200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostPork200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postPorkAsync + * + * Perform pork calculation + * + * @param \OpenAPI\Client\Model\PostPorkRequest $post_pork_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPork'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postPorkAsync($post_pork_request, string $contentType = self::contentTypes['postPork'][0]) + { + return $this->postPorkAsyncWithHttpInfo($post_pork_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postPorkAsyncWithHttpInfo + * + * Perform pork calculation + * + * @param \OpenAPI\Client\Model\PostPorkRequest $post_pork_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPork'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postPorkAsyncWithHttpInfo($post_pork_request, string $contentType = self::contentTypes['postPork'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostPork200Response'; + $request = $this->postPorkRequest($post_pork_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postPork' + * + * @param \OpenAPI\Client\Model\PostPorkRequest $post_pork_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPork'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postPorkRequest($post_pork_request, string $contentType = self::contentTypes['postPork'][0]) + { + + // verify the required parameter 'post_pork_request' is set + if ($post_pork_request === null || (is_array($post_pork_request) && count($post_pork_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_pork_request when calling postPork' + ); + } + + + $resourcePath = '/pork'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_pork_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_pork_request)); + } else { + $httpBody = $post_pork_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postPoultry + * + * Perform poultry calculation + * + * @param \OpenAPI\Client\Model\PostPoultryRequest $post_poultry_request post_poultry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPoultry'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostPoultry200Response + */ + public function postPoultry($post_poultry_request, string $contentType = self::contentTypes['postPoultry'][0]) + { + list($response) = $this->postPoultryWithHttpInfo($post_poultry_request, $contentType); + return $response; + } + + /** + * Operation postPoultryWithHttpInfo + * + * Perform poultry calculation + * + * @param \OpenAPI\Client\Model\PostPoultryRequest $post_poultry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPoultry'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostPoultry200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postPoultryWithHttpInfo($post_poultry_request, string $contentType = self::contentTypes['postPoultry'][0]) + { + $request = $this->postPoultryRequest($post_poultry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostPoultry200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostPoultry200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostPoultry200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postPoultryAsync + * + * Perform poultry calculation + * + * @param \OpenAPI\Client\Model\PostPoultryRequest $post_poultry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPoultry'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postPoultryAsync($post_poultry_request, string $contentType = self::contentTypes['postPoultry'][0]) + { + return $this->postPoultryAsyncWithHttpInfo($post_poultry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postPoultryAsyncWithHttpInfo + * + * Perform poultry calculation + * + * @param \OpenAPI\Client\Model\PostPoultryRequest $post_poultry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPoultry'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postPoultryAsyncWithHttpInfo($post_poultry_request, string $contentType = self::contentTypes['postPoultry'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostPoultry200Response'; + $request = $this->postPoultryRequest($post_poultry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postPoultry' + * + * @param \OpenAPI\Client\Model\PostPoultryRequest $post_poultry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postPoultry'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postPoultryRequest($post_poultry_request, string $contentType = self::contentTypes['postPoultry'][0]) + { + + // verify the required parameter 'post_poultry_request' is set + if ($post_poultry_request === null || (is_array($post_poultry_request) && count($post_poultry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_poultry_request when calling postPoultry' + ); + } + + + $resourcePath = '/poultry'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_poultry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_poultry_request)); + } else { + $httpBody = $post_poultry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postProcessing + * + * Perform processing calculation + * + * @param \OpenAPI\Client\Model\PostProcessingRequest $post_processing_request post_processing_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postProcessing'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostProcessing200Response + */ + public function postProcessing($post_processing_request, string $contentType = self::contentTypes['postProcessing'][0]) + { + list($response) = $this->postProcessingWithHttpInfo($post_processing_request, $contentType); + return $response; + } + + /** + * Operation postProcessingWithHttpInfo + * + * Perform processing calculation + * + * @param \OpenAPI\Client\Model\PostProcessingRequest $post_processing_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postProcessing'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostProcessing200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postProcessingWithHttpInfo($post_processing_request, string $contentType = self::contentTypes['postProcessing'][0]) + { + $request = $this->postProcessingRequest($post_processing_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostProcessing200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostProcessing200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostProcessing200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postProcessingAsync + * + * Perform processing calculation + * + * @param \OpenAPI\Client\Model\PostProcessingRequest $post_processing_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postProcessing'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postProcessingAsync($post_processing_request, string $contentType = self::contentTypes['postProcessing'][0]) + { + return $this->postProcessingAsyncWithHttpInfo($post_processing_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postProcessingAsyncWithHttpInfo + * + * Perform processing calculation + * + * @param \OpenAPI\Client\Model\PostProcessingRequest $post_processing_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postProcessing'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postProcessingAsyncWithHttpInfo($post_processing_request, string $contentType = self::contentTypes['postProcessing'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostProcessing200Response'; + $request = $this->postProcessingRequest($post_processing_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postProcessing' + * + * @param \OpenAPI\Client\Model\PostProcessingRequest $post_processing_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postProcessing'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postProcessingRequest($post_processing_request, string $contentType = self::contentTypes['postProcessing'][0]) + { + + // verify the required parameter 'post_processing_request' is set + if ($post_processing_request === null || (is_array($post_processing_request) && count($post_processing_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_processing_request when calling postProcessing' + ); + } + + + $resourcePath = '/processing'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_processing_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_processing_request)); + } else { + $httpBody = $post_processing_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postRice + * + * Perform rice calculation + * + * @param \OpenAPI\Client\Model\PostRiceRequest $post_rice_request post_rice_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postRice'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostRice200Response + */ + public function postRice($post_rice_request, string $contentType = self::contentTypes['postRice'][0]) + { + list($response) = $this->postRiceWithHttpInfo($post_rice_request, $contentType); + return $response; + } + + /** + * Operation postRiceWithHttpInfo + * + * Perform rice calculation + * + * @param \OpenAPI\Client\Model\PostRiceRequest $post_rice_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postRice'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostRice200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postRiceWithHttpInfo($post_rice_request, string $contentType = self::contentTypes['postRice'][0]) + { + $request = $this->postRiceRequest($post_rice_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostRice200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostRice200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostRice200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postRiceAsync + * + * Perform rice calculation + * + * @param \OpenAPI\Client\Model\PostRiceRequest $post_rice_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postRice'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postRiceAsync($post_rice_request, string $contentType = self::contentTypes['postRice'][0]) + { + return $this->postRiceAsyncWithHttpInfo($post_rice_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postRiceAsyncWithHttpInfo + * + * Perform rice calculation + * + * @param \OpenAPI\Client\Model\PostRiceRequest $post_rice_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postRice'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postRiceAsyncWithHttpInfo($post_rice_request, string $contentType = self::contentTypes['postRice'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostRice200Response'; + $request = $this->postRiceRequest($post_rice_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postRice' + * + * @param \OpenAPI\Client\Model\PostRiceRequest $post_rice_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postRice'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postRiceRequest($post_rice_request, string $contentType = self::contentTypes['postRice'][0]) + { + + // verify the required parameter 'post_rice_request' is set + if ($post_rice_request === null || (is_array($post_rice_request) && count($post_rice_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_rice_request when calling postRice' + ); + } + + + $resourcePath = '/rice'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_rice_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_rice_request)); + } else { + $httpBody = $post_rice_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postSheep + * + * Perform sheep calculation + * + * @param \OpenAPI\Client\Model\PostSheepRequest $post_sheep_request post_sheep_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheep'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostSheep200Response + */ + public function postSheep($post_sheep_request, string $contentType = self::contentTypes['postSheep'][0]) + { + list($response) = $this->postSheepWithHttpInfo($post_sheep_request, $contentType); + return $response; + } + + /** + * Operation postSheepWithHttpInfo + * + * Perform sheep calculation + * + * @param \OpenAPI\Client\Model\PostSheepRequest $post_sheep_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheep'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostSheep200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postSheepWithHttpInfo($post_sheep_request, string $contentType = self::contentTypes['postSheep'][0]) + { + $request = $this->postSheepRequest($post_sheep_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSheep200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSheep200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostSheep200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postSheepAsync + * + * Perform sheep calculation + * + * @param \OpenAPI\Client\Model\PostSheepRequest $post_sheep_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheep'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSheepAsync($post_sheep_request, string $contentType = self::contentTypes['postSheep'][0]) + { + return $this->postSheepAsyncWithHttpInfo($post_sheep_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postSheepAsyncWithHttpInfo + * + * Perform sheep calculation + * + * @param \OpenAPI\Client\Model\PostSheepRequest $post_sheep_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheep'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSheepAsyncWithHttpInfo($post_sheep_request, string $contentType = self::contentTypes['postSheep'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostSheep200Response'; + $request = $this->postSheepRequest($post_sheep_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postSheep' + * + * @param \OpenAPI\Client\Model\PostSheepRequest $post_sheep_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheep'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postSheepRequest($post_sheep_request, string $contentType = self::contentTypes['postSheep'][0]) + { + + // verify the required parameter 'post_sheep_request' is set + if ($post_sheep_request === null || (is_array($post_sheep_request) && count($post_sheep_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_sheep_request when calling postSheep' + ); + } + + + $resourcePath = '/sheep'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_sheep_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_sheep_request)); + } else { + $httpBody = $post_sheep_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postSheepbeef + * + * Perform sheepbeef calculation + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequest $post_sheepbeef_request post_sheepbeef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheepbeef'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostSheepbeef200Response + */ + public function postSheepbeef($post_sheepbeef_request, string $contentType = self::contentTypes['postSheepbeef'][0]) + { + list($response) = $this->postSheepbeefWithHttpInfo($post_sheepbeef_request, $contentType); + return $response; + } + + /** + * Operation postSheepbeefWithHttpInfo + * + * Perform sheepbeef calculation + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequest $post_sheepbeef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheepbeef'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostSheepbeef200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postSheepbeefWithHttpInfo($post_sheepbeef_request, string $contentType = self::contentTypes['postSheepbeef'][0]) + { + $request = $this->postSheepbeefRequest($post_sheepbeef_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSheepbeef200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSheepbeef200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostSheepbeef200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postSheepbeefAsync + * + * Perform sheepbeef calculation + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequest $post_sheepbeef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheepbeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSheepbeefAsync($post_sheepbeef_request, string $contentType = self::contentTypes['postSheepbeef'][0]) + { + return $this->postSheepbeefAsyncWithHttpInfo($post_sheepbeef_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postSheepbeefAsyncWithHttpInfo + * + * Perform sheepbeef calculation + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequest $post_sheepbeef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheepbeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSheepbeefAsyncWithHttpInfo($post_sheepbeef_request, string $contentType = self::contentTypes['postSheepbeef'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostSheepbeef200Response'; + $request = $this->postSheepbeefRequest($post_sheepbeef_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postSheepbeef' + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequest $post_sheepbeef_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSheepbeef'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postSheepbeefRequest($post_sheepbeef_request, string $contentType = self::contentTypes['postSheepbeef'][0]) + { + + // verify the required parameter 'post_sheepbeef_request' is set + if ($post_sheepbeef_request === null || (is_array($post_sheepbeef_request) && count($post_sheepbeef_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_sheepbeef_request when calling postSheepbeef' + ); + } + + + $resourcePath = '/sheepbeef'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_sheepbeef_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_sheepbeef_request)); + } else { + $httpBody = $post_sheepbeef_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postSugar + * + * Perform sugar calculation + * + * @param \OpenAPI\Client\Model\PostSugarRequest $post_sugar_request post_sugar_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSugar'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostSugar200Response + */ + public function postSugar($post_sugar_request, string $contentType = self::contentTypes['postSugar'][0]) + { + list($response) = $this->postSugarWithHttpInfo($post_sugar_request, $contentType); + return $response; + } + + /** + * Operation postSugarWithHttpInfo + * + * Perform sugar calculation + * + * @param \OpenAPI\Client\Model\PostSugarRequest $post_sugar_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSugar'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostSugar200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postSugarWithHttpInfo($post_sugar_request, string $contentType = self::contentTypes['postSugar'][0]) + { + $request = $this->postSugarRequest($post_sugar_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSugar200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostSugar200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostSugar200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postSugarAsync + * + * Perform sugar calculation + * + * @param \OpenAPI\Client\Model\PostSugarRequest $post_sugar_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSugar'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSugarAsync($post_sugar_request, string $contentType = self::contentTypes['postSugar'][0]) + { + return $this->postSugarAsyncWithHttpInfo($post_sugar_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postSugarAsyncWithHttpInfo + * + * Perform sugar calculation + * + * @param \OpenAPI\Client\Model\PostSugarRequest $post_sugar_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSugar'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postSugarAsyncWithHttpInfo($post_sugar_request, string $contentType = self::contentTypes['postSugar'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostSugar200Response'; + $request = $this->postSugarRequest($post_sugar_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postSugar' + * + * @param \OpenAPI\Client\Model\PostSugarRequest $post_sugar_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postSugar'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postSugarRequest($post_sugar_request, string $contentType = self::contentTypes['postSugar'][0]) + { + + // verify the required parameter 'post_sugar_request' is set + if ($post_sugar_request === null || (is_array($post_sugar_request) && count($post_sugar_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_sugar_request when calling postSugar' + ); + } + + + $resourcePath = '/sugar'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_sugar_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_sugar_request)); + } else { + $httpBody = $post_sugar_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postVineyard + * + * Perform vineyard calculation + * + * @param \OpenAPI\Client\Model\PostVineyardRequest $post_vineyard_request post_vineyard_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postVineyard'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostVineyard200Response + */ + public function postVineyard($post_vineyard_request, string $contentType = self::contentTypes['postVineyard'][0]) + { + list($response) = $this->postVineyardWithHttpInfo($post_vineyard_request, $contentType); + return $response; + } + + /** + * Operation postVineyardWithHttpInfo + * + * Perform vineyard calculation + * + * @param \OpenAPI\Client\Model\PostVineyardRequest $post_vineyard_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postVineyard'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostVineyard200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postVineyardWithHttpInfo($post_vineyard_request, string $contentType = self::contentTypes['postVineyard'][0]) + { + $request = $this->postVineyardRequest($post_vineyard_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostVineyard200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostVineyard200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostVineyard200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postVineyardAsync + * + * Perform vineyard calculation + * + * @param \OpenAPI\Client\Model\PostVineyardRequest $post_vineyard_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postVineyard'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postVineyardAsync($post_vineyard_request, string $contentType = self::contentTypes['postVineyard'][0]) + { + return $this->postVineyardAsyncWithHttpInfo($post_vineyard_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postVineyardAsyncWithHttpInfo + * + * Perform vineyard calculation + * + * @param \OpenAPI\Client\Model\PostVineyardRequest $post_vineyard_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postVineyard'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postVineyardAsyncWithHttpInfo($post_vineyard_request, string $contentType = self::contentTypes['postVineyard'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostVineyard200Response'; + $request = $this->postVineyardRequest($post_vineyard_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postVineyard' + * + * @param \OpenAPI\Client\Model\PostVineyardRequest $post_vineyard_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postVineyard'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postVineyardRequest($post_vineyard_request, string $contentType = self::contentTypes['postVineyard'][0]) + { + + // verify the required parameter 'post_vineyard_request' is set + if ($post_vineyard_request === null || (is_array($post_vineyard_request) && count($post_vineyard_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_vineyard_request when calling postVineyard' + ); + } + + + $resourcePath = '/vineyard'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_vineyard_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_vineyard_request)); + } else { + $httpBody = $post_vineyard_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postWildcatchfishery + * + * Perform wildcatchfishery calculation + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequest $post_wildcatchfishery_request post_wildcatchfishery_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildcatchfishery'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostWildcatchfishery200Response + */ + public function postWildcatchfishery($post_wildcatchfishery_request, string $contentType = self::contentTypes['postWildcatchfishery'][0]) + { + list($response) = $this->postWildcatchfisheryWithHttpInfo($post_wildcatchfishery_request, $contentType); + return $response; + } + + /** + * Operation postWildcatchfisheryWithHttpInfo + * + * Perform wildcatchfishery calculation + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequest $post_wildcatchfishery_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildcatchfishery'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostWildcatchfishery200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postWildcatchfisheryWithHttpInfo($post_wildcatchfishery_request, string $contentType = self::contentTypes['postWildcatchfishery'][0]) + { + $request = $this->postWildcatchfisheryRequest($post_wildcatchfishery_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostWildcatchfishery200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostWildcatchfishery200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostWildcatchfishery200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postWildcatchfisheryAsync + * + * Perform wildcatchfishery calculation + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequest $post_wildcatchfishery_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildcatchfishery'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postWildcatchfisheryAsync($post_wildcatchfishery_request, string $contentType = self::contentTypes['postWildcatchfishery'][0]) + { + return $this->postWildcatchfisheryAsyncWithHttpInfo($post_wildcatchfishery_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postWildcatchfisheryAsyncWithHttpInfo + * + * Perform wildcatchfishery calculation + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequest $post_wildcatchfishery_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildcatchfishery'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postWildcatchfisheryAsyncWithHttpInfo($post_wildcatchfishery_request, string $contentType = self::contentTypes['postWildcatchfishery'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostWildcatchfishery200Response'; + $request = $this->postWildcatchfisheryRequest($post_wildcatchfishery_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postWildcatchfishery' + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequest $post_wildcatchfishery_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildcatchfishery'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postWildcatchfisheryRequest($post_wildcatchfishery_request, string $contentType = self::contentTypes['postWildcatchfishery'][0]) + { + + // verify the required parameter 'post_wildcatchfishery_request' is set + if ($post_wildcatchfishery_request === null || (is_array($post_wildcatchfishery_request) && count($post_wildcatchfishery_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_wildcatchfishery_request when calling postWildcatchfishery' + ); + } + + + $resourcePath = '/wildcatchfishery'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_wildcatchfishery_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_wildcatchfishery_request)); + } else { + $httpBody = $post_wildcatchfishery_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation postWildseafisheries + * + * Perform wildseafisheries calculation + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequest $post_wildseafisheries_request post_wildseafisheries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildseafisheries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\PostWildseafisheries200Response + */ + public function postWildseafisheries($post_wildseafisheries_request, string $contentType = self::contentTypes['postWildseafisheries'][0]) + { + list($response) = $this->postWildseafisheriesWithHttpInfo($post_wildseafisheries_request, $contentType); + return $response; + } + + /** + * Operation postWildseafisheriesWithHttpInfo + * + * Perform wildseafisheries calculation + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequest $post_wildseafisheries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildseafisheries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\PostWildseafisheries200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function postWildseafisheriesWithHttpInfo($post_wildseafisheries_request, string $contentType = self::contentTypes['postWildseafisheries'][0]) + { + $request = $this->postWildseafisheriesRequest($post_wildseafisheries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostWildseafisheries200Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\PostWildseafisheries200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\PostWildseafisheries200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation postWildseafisheriesAsync + * + * Perform wildseafisheries calculation + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequest $post_wildseafisheries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildseafisheries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postWildseafisheriesAsync($post_wildseafisheries_request, string $contentType = self::contentTypes['postWildseafisheries'][0]) + { + return $this->postWildseafisheriesAsyncWithHttpInfo($post_wildseafisheries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation postWildseafisheriesAsyncWithHttpInfo + * + * Perform wildseafisheries calculation + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequest $post_wildseafisheries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildseafisheries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function postWildseafisheriesAsyncWithHttpInfo($post_wildseafisheries_request, string $contentType = self::contentTypes['postWildseafisheries'][0]) + { + $returnType = '\OpenAPI\Client\Model\PostWildseafisheries200Response'; + $request = $this->postWildseafisheriesRequest($post_wildseafisheries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'postWildseafisheries' + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequest $post_wildseafisheries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postWildseafisheries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function postWildseafisheriesRequest($post_wildseafisheries_request, string $contentType = self::contentTypes['postWildseafisheries'][0]) + { + + // verify the required parameter 'post_wildseafisheries_request' is set + if ($post_wildseafisheries_request === null || (is_array($post_wildseafisheries_request) && count($post_wildseafisheries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $post_wildseafisheries_request when calling postWildseafisheries' + ); + } + + + $resourcePath = '/wildseafisheries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json',], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($post_wildseafisheries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($post_wildseafisheries_request)); + } else { + $httpBody = $post_wildseafisheries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $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()); + } + } + + if ($this->config->getCertFile()) { + $options[RequestOptions::CERT] = $this->config->getCertFile(); + } + + if ($this->config->getKeyFile()) { + $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); + } + + return $options; + } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0] . '00'); + $right = (int) ($rangeCode[0] . '99'); + + return $statusCode >= $left && $statusCode <= $right; + } +} diff --git a/examples/php-api-client/api-client/lib/ApiException.php b/examples/php-api-client/api-client/lib/ApiException.php new file mode 100644 index 00000000..7fae89ef --- /dev/null +++ b/examples/php-api-client/api-client/lib/ApiException.php @@ -0,0 +1,120 @@ +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/examples/php-api-client/api-client/lib/Configuration.php b/examples/php-api-client/api-client/lib/Configuration.php new file mode 100644 index 00000000..07febae4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Configuration.php @@ -0,0 +1,589 @@ +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; + } + + + /** + * Sets the certificate file path, for mTLS + * + * @return $this + */ + public function setCertFile($certFile) + { + $this->certFile = $certFile; + return $this; + } + + /** + * Gets the certificate file path, for mTLS + * + * @return string Certificate file path + */ + public function getCertFile() + { + return $this->certFile; + } + + /** + * Sets the certificate key path, for mTLS + * + * @return $this + */ + public function setKeyFile($keyFile) + { + $this->keyFile = $keyFile; + return $this; + } + + /** + * Gets the certificate key path, for mTLS + * + * @return string Certificate key path + */ + public function getKeyFile() + { + return $this->keyFile; + } + + /** + * 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: 3.0.0' . 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://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0", + "description" => "Production Server", + ] + ]; + } + + /** + * 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/examples/php-api-client/api-client/lib/FormDataProcessor.php b/examples/php-api-client/api-client/lib/FormDataProcessor.php new file mode 100644 index 00000000..5370b249 --- /dev/null +++ b/examples/php-api-client/api-client/lib/FormDataProcessor.php @@ -0,0 +1,247 @@ + $values the value of the form parameter + * + * @return array [key => value] of formdata + */ + public function prepare(array $values): array + { + $this->has_file = false; + $result = []; + + foreach ($values as $k => $v) { + if ($v === null) { + continue; + } + + $result[$k] = $this->makeFormSafe($v); + } + + return $result; + } + + /** + * Flattens a multi-level array of data and generates a single-level array + * compatible with formdata - a single-level array where the keys use bracket + * notation to signify nested data. + * + * credit: https://github.com/FranBar1966/FlatPHP + */ + public static function flatten(array $source, string $start = ''): array + { + $opt = [ + 'prefix' => '[', + 'suffix' => ']', + 'suffix-end' => true, + 'prefix-list' => '[', + 'suffix-list' => ']', + 'suffix-list-end' => true, + ]; + + if ($start === '') { + $currentPrefix = ''; + $currentSuffix = ''; + $currentSuffixEnd = false; + } elseif (array_is_list($source)) { + $currentPrefix = $opt['prefix-list']; + $currentSuffix = $opt['suffix-list']; + $currentSuffixEnd = $opt['suffix-list-end']; + } else { + $currentPrefix = $opt['prefix']; + $currentSuffix = $opt['suffix']; + $currentSuffixEnd = $opt['suffix-end']; + } + + $currentName = $start; + $result = []; + + foreach ($source as $key => $val) { + $currentName .= $currentPrefix.$key; + + if (is_array($val) && !empty($val)) { + $currentName .= $currentSuffix; + $result += self::flatten($val, $currentName); + } else { + if ($currentSuffixEnd) { + $currentName .= $currentSuffix; + } + + if (is_resource($val)) { + $result[$currentName] = $val; + } else { + $result[$currentName] = ObjectSerializer::toString($val); + } + } + + $currentName = $start; + } + + return $result; + } + + /** + * formdata must be limited to scalars or arrays of scalar values, + * or a resource for a file upload. Here we iterate through all available + * data and identify how to handle each scenario + */ + protected function makeFormSafe($value) + { + if ($value instanceof SplFileObject) { + return $this->processFiles([$value])[0]; + } + + if (is_resource($value)) { + $this->has_file = true; + + return $value; + } + + if ($value instanceof ModelInterface) { + return $this->processModel($value); + } + + if (is_array($value) || (is_object($value) && !$value instanceof \DateTimeInterface)) { + $data = []; + + foreach ($value as $k => $v) { + $data[$k] = $this->makeFormSafe($v); + } + + return $data; + } + + return ObjectSerializer::toString($value); + } + + /** + * We are able to handle nested ModelInterface. We do not simply call + * json_decode(json_encode()) because any given model may have binary data + * or other data that cannot be serialized to a JSON string + */ + protected function processModel(ModelInterface $model): array + { + $result = []; + + foreach ($model::openAPITypes() as $name => $type) { + $value = $model->offsetGet($name); + + if ($value === null) { + continue; + } + + if (strpos($type, '\SplFileObject') !== false) { + $file = is_array($value) ? $value : [$value]; + $result[$name] = $this->processFiles($file); + + continue; + } + + if ($value instanceof ModelInterface) { + $result[$name] = $this->processModel($value); + + continue; + } + + if (is_array($value) || is_object($value)) { + $result[$name] = $this->makeFormSafe($value); + + continue; + } + + $result[$name] = ObjectSerializer::toString($value); + } + + return $result; + } + + /** + * Handle file data + */ + protected function processFiles(array $files): array + { + $this->has_file = true; + + $result = []; + + foreach ($files as $i => $file) { + if (is_array($file)) { + $result[$i] = $this->processFiles($file); + + continue; + } + + if ($file instanceof StreamInterface) { + $result[$i] = $file; + + continue; + } + + if ($file instanceof SplFileObject) { + $result[$i] = $this->tryFopen($file); + } + } + + return $result; + } + + private function tryFopen(SplFileObject $file) + { + return Utils::tryFopen($file->getRealPath(), 'rb'); + } +} diff --git a/examples/php-api-client/api-client/lib/HeaderSelector.php b/examples/php-api-client/api-client/lib/HeaderSelector.php new file mode 100644 index 00000000..5982425a --- /dev/null +++ b/examples/php-api-client/api-client/lib/HeaderSelector.php @@ -0,0 +1,274 @@ +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/examples/php-api-client/api-client/lib/Model/ModelInterface.php b/examples/php-api-client/api-client/lib/Model/ModelInterface.php new file mode 100644 index 00000000..7e417d89 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/ModelInterface.php @@ -0,0 +1,112 @@ + + */ +class PostAquaculture200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope3', + 'purchased_offsets' => '\OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'purchased_offsets' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'purchased_offsets' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'purchased_offsets' => 'purchasedOffsets', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'purchased_offsets' => 'setPurchasedOffsets', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'purchased_offsets' => 'getPurchasedOffsets', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('purchased_offsets', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['purchased_offsets'] === null) { + $invalidProperties[] = "'purchased_offsets' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets purchased_offsets + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets + */ + public function getPurchasedOffsets() + { + return $this->container['purchased_offsets']; + } + + /** + * Sets purchased_offsets + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets $purchased_offsets purchased_offsets + * + * @return self + */ + public function setPurchasedOffsets($purchased_offsets) + { + if (is_null($purchased_offsets)) { + throw new \InvalidArgumentException('non-nullable purchased_offsets cannot be null'); + } + $this->container['purchased_offsets'] = $purchased_offsets; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseCarbonSequestration.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseCarbonSequestration.php new file mode 100644 index 00000000..ee22da28 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseCarbonSequestration.php @@ -0,0 +1,451 @@ + + */ +class PostAquaculture200ResponseCarbonSequestration implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_carbonSequestration'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'intermediate' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Annual amount of carbon sequestered, in tonnes-CO2e + * + * @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 intermediate + * + * @return float[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param float[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntensities.php new file mode 100644 index 00000000..6cd55349 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostAquaculture200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total_harvest_weight_kg' => 'float', + 'aquaculture_excluding_carbon_offsets' => 'float', + 'aquaculture_including_carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total_harvest_weight_kg' => null, + 'aquaculture_excluding_carbon_offsets' => null, + 'aquaculture_including_carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total_harvest_weight_kg' => false, + 'aquaculture_excluding_carbon_offsets' => false, + 'aquaculture_including_carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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_harvest_weight_kg' => 'totalHarvestWeightKg', + 'aquaculture_excluding_carbon_offsets' => 'aquacultureExcludingCarbonOffsets', + 'aquaculture_including_carbon_offsets' => 'aquacultureIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total_harvest_weight_kg' => 'setTotalHarvestWeightKg', + 'aquaculture_excluding_carbon_offsets' => 'setAquacultureExcludingCarbonOffsets', + 'aquaculture_including_carbon_offsets' => 'setAquacultureIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total_harvest_weight_kg' => 'getTotalHarvestWeightKg', + 'aquaculture_excluding_carbon_offsets' => 'getAquacultureExcludingCarbonOffsets', + 'aquaculture_including_carbon_offsets' => 'getAquacultureIncludingCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total_harvest_weight_kg', $data ?? [], null); + $this->setIfExists('aquaculture_excluding_carbon_offsets', $data ?? [], null); + $this->setIfExists('aquaculture_including_carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total_harvest_weight_kg'] === null) { + $invalidProperties[] = "'total_harvest_weight_kg' can't be null"; + } + if ($this->container['aquaculture_excluding_carbon_offsets'] === null) { + $invalidProperties[] = "'aquaculture_excluding_carbon_offsets' can't be null"; + } + if ($this->container['aquaculture_including_carbon_offsets'] === null) { + $invalidProperties[] = "'aquaculture_including_carbon_offsets' 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 total_harvest_weight_kg + * + * @return float + */ + public function getTotalHarvestWeightKg() + { + return $this->container['total_harvest_weight_kg']; + } + + /** + * Sets total_harvest_weight_kg + * + * @param float $total_harvest_weight_kg Total harvest weight in kg + * + * @return self + */ + public function setTotalHarvestWeightKg($total_harvest_weight_kg) + { + if (is_null($total_harvest_weight_kg)) { + throw new \InvalidArgumentException('non-nullable total_harvest_weight_kg cannot be null'); + } + $this->container['total_harvest_weight_kg'] = $total_harvest_weight_kg; + + return $this; + } + + /** + * Gets aquaculture_excluding_carbon_offsets + * + * @return float + */ + public function getAquacultureExcludingCarbonOffsets() + { + return $this->container['aquaculture_excluding_carbon_offsets']; + } + + /** + * Sets aquaculture_excluding_carbon_offsets + * + * @param float $aquaculture_excluding_carbon_offsets Aquaculture emissions intensity excluding sequestration, in kg-CO2e/kg + * + * @return self + */ + public function setAquacultureExcludingCarbonOffsets($aquaculture_excluding_carbon_offsets) + { + if (is_null($aquaculture_excluding_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable aquaculture_excluding_carbon_offsets cannot be null'); + } + $this->container['aquaculture_excluding_carbon_offsets'] = $aquaculture_excluding_carbon_offsets; + + return $this; + } + + /** + * Gets aquaculture_including_carbon_offsets + * + * @return float + */ + public function getAquacultureIncludingCarbonOffsets() + { + return $this->container['aquaculture_including_carbon_offsets']; + } + + /** + * Sets aquaculture_including_carbon_offsets + * + * @param float $aquaculture_including_carbon_offsets Aquaculture emissions intensity including sequestration, in kg-CO2e/kg + * + * @return self + */ + public function setAquacultureIncludingCarbonOffsets($aquaculture_including_carbon_offsets) + { + if (is_null($aquaculture_including_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable aquaculture_including_carbon_offsets cannot be null'); + } + $this->container['aquaculture_including_carbon_offsets'] = $aquaculture_including_carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInner.php new file mode 100644 index 00000000..0fbdf186 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostAquaculture200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope3', + 'intensities' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'intensities' => null, + 'net' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'intensities' => false, + 'net' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'intensities' => 'intensities', + 'net' => 'net', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'intensities' => 'setIntensities', + 'net' => 'setNet', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'intensities' => 'getIntensities', + 'net' => 'getNet', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.php new file mode 100644 index 00000000..b5ae07b0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.php @@ -0,0 +1,414 @@ + + */ +class PostAquaculture200ResponseIntermediateInnerCarbonSequestration implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_intermediate_inner_carbonSequestration'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Annual amount of carbon sequestered, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseNet.php new file mode 100644 index 00000000..9b4ac981 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostAquaculture200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponsePurchasedOffsets.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponsePurchasedOffsets.php new file mode 100644 index 00000000..ab499066 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponsePurchasedOffsets.php @@ -0,0 +1,414 @@ + + */ +class PostAquaculture200ResponsePurchasedOffsets implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_purchasedOffsets'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Annual amount of carbon sequestered, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope1.php new file mode 100644 index 00000000..2ca29242 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope1.php @@ -0,0 +1,784 @@ + + */ +class PostAquaculture200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'hfcs_refrigerant_leakage' => 'float', + 'waste_water_co2' => 'float', + 'composted_solid_waste_co2' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total_hfcs' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'hfcs_refrigerant_leakage' => null, + 'waste_water_co2' => null, + 'composted_solid_waste_co2' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total_hfcs' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'hfcs_refrigerant_leakage' => false, + 'waste_water_co2' => false, + 'composted_solid_waste_co2' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => false, + 'total_hfcs' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'hfcs_refrigerant_leakage' => 'hfcsRefrigerantLeakage', + 'waste_water_co2' => 'wasteWaterCO2', + 'composted_solid_waste_co2' => 'compostedSolidWasteCO2', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total_hfcs' => 'totalHFCs', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'hfcs_refrigerant_leakage' => 'setHfcsRefrigerantLeakage', + 'waste_water_co2' => 'setWasteWaterCo2', + 'composted_solid_waste_co2' => 'setCompostedSolidWasteCo2', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total_hfcs' => 'setTotalHfcs', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'hfcs_refrigerant_leakage' => 'getHfcsRefrigerantLeakage', + 'waste_water_co2' => 'getWasteWaterCo2', + 'composted_solid_waste_co2' => 'getCompostedSolidWasteCo2', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + 'total_hfcs' => 'getTotalHfcs', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('hfcs_refrigerant_leakage', $data ?? [], null); + $this->setIfExists('waste_water_co2', $data ?? [], null); + $this->setIfExists('composted_solid_waste_co2', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $data ?? [], null); + $this->setIfExists('total_hfcs', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['hfcs_refrigerant_leakage'] === null) { + $invalidProperties[] = "'hfcs_refrigerant_leakage' can't be null"; + } + if ($this->container['waste_water_co2'] === null) { + $invalidProperties[] = "'waste_water_co2' can't be null"; + } + if ($this->container['composted_solid_waste_co2'] === null) { + $invalidProperties[] = "'composted_solid_waste_co2' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total_hfcs'] === null) { + $invalidProperties[] = "'total_hfcs' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets hfcs_refrigerant_leakage + * + * @return float + */ + public function getHfcsRefrigerantLeakage() + { + return $this->container['hfcs_refrigerant_leakage']; + } + + /** + * Sets hfcs_refrigerant_leakage + * + * @param float $hfcs_refrigerant_leakage Emissions from refrigerant leakage, in tonnes-HFCs + * + * @return self + */ + public function setHfcsRefrigerantLeakage($hfcs_refrigerant_leakage) + { + if (is_null($hfcs_refrigerant_leakage)) { + throw new \InvalidArgumentException('non-nullable hfcs_refrigerant_leakage cannot be null'); + } + $this->container['hfcs_refrigerant_leakage'] = $hfcs_refrigerant_leakage; + + return $this; + } + + /** + * Gets waste_water_co2 + * + * @return float + */ + public function getWasteWaterCo2() + { + return $this->container['waste_water_co2']; + } + + /** + * Sets waste_water_co2 + * + * @param float $waste_water_co2 Emissions from wastewater, in tonnes-CO2e + * + * @return self + */ + public function setWasteWaterCo2($waste_water_co2) + { + if (is_null($waste_water_co2)) { + throw new \InvalidArgumentException('non-nullable waste_water_co2 cannot be null'); + } + $this->container['waste_water_co2'] = $waste_water_co2; + + return $this; + } + + /** + * Gets composted_solid_waste_co2 + * + * @return float + */ + public function getCompostedSolidWasteCo2() + { + return $this->container['composted_solid_waste_co2']; + } + + /** + * Sets composted_solid_waste_co2 + * + * @param float $composted_solid_waste_co2 Emissions from composted solid waste, in tonnes-CO2e + * + * @return self + */ + public function setCompostedSolidWasteCo2($composted_solid_waste_co2) + { + if (is_null($composted_solid_waste_co2)) { + throw new \InvalidArgumentException('non-nullable composted_solid_waste_co2 cannot be null'); + } + $this->container['composted_solid_waste_co2'] = $composted_solid_waste_co2; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total_hfcs + * + * @return float + */ + public function getTotalHfcs() + { + return $this->container['total_hfcs']; + } + + /** + * Sets total_hfcs + * + * @param float $total_hfcs Total HFCs scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalHfcs($total_hfcs) + { + if (is_null($total_hfcs)) { + throw new \InvalidArgumentException('non-nullable total_hfcs cannot be null'); + } + $this->container['total_hfcs'] = $total_hfcs; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope2.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope2.php new file mode 100644 index 00000000..10210c96 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope2.php @@ -0,0 +1,451 @@ + + */ +class PostAquaculture200ResponseScope2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_scope2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'electricity' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'electricity' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'electricity' => 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 = [ + 'electricity' => 'electricity', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'electricity' => 'setElectricity', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'electricity' => 'getElectricity', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('electricity', $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['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 2 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope3.php new file mode 100644 index 00000000..fb9dc9c1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquaculture200ResponseScope3.php @@ -0,0 +1,673 @@ + + */ +class PostAquaculture200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'purchased_bait' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'commercial_flights' => 'float', + 'inbound_freight' => 'float', + 'outbound_freight' => 'float', + 'solid_waste_sent_offsite' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'purchased_bait' => null, + 'electricity' => null, + 'fuel' => null, + 'commercial_flights' => null, + 'inbound_freight' => null, + 'outbound_freight' => null, + 'solid_waste_sent_offsite' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'purchased_bait' => false, + 'electricity' => false, + 'fuel' => false, + 'commercial_flights' => false, + 'inbound_freight' => false, + 'outbound_freight' => false, + 'solid_waste_sent_offsite' => 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 = [ + 'purchased_bait' => 'purchasedBait', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'commercial_flights' => 'commercialFlights', + 'inbound_freight' => 'inboundFreight', + 'outbound_freight' => 'outboundFreight', + 'solid_waste_sent_offsite' => 'solidWasteSentOffsite', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'purchased_bait' => 'setPurchasedBait', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'commercial_flights' => 'setCommercialFlights', + 'inbound_freight' => 'setInboundFreight', + 'outbound_freight' => 'setOutboundFreight', + 'solid_waste_sent_offsite' => 'setSolidWasteSentOffsite', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'purchased_bait' => 'getPurchasedBait', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'commercial_flights' => 'getCommercialFlights', + 'inbound_freight' => 'getInboundFreight', + 'outbound_freight' => 'getOutboundFreight', + 'solid_waste_sent_offsite' => 'getSolidWasteSentOffsite', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('purchased_bait', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('commercial_flights', $data ?? [], null); + $this->setIfExists('inbound_freight', $data ?? [], null); + $this->setIfExists('outbound_freight', $data ?? [], null); + $this->setIfExists('solid_waste_sent_offsite', $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['purchased_bait'] === null) { + $invalidProperties[] = "'purchased_bait' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['commercial_flights'] === null) { + $invalidProperties[] = "'commercial_flights' can't be null"; + } + if ($this->container['inbound_freight'] === null) { + $invalidProperties[] = "'inbound_freight' can't be null"; + } + if ($this->container['outbound_freight'] === null) { + $invalidProperties[] = "'outbound_freight' can't be null"; + } + if ($this->container['solid_waste_sent_offsite'] === null) { + $invalidProperties[] = "'solid_waste_sent_offsite' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 purchased_bait + * + * @return float + */ + public function getPurchasedBait() + { + return $this->container['purchased_bait']; + } + + /** + * Sets purchased_bait + * + * @param float $purchased_bait Emissions from purchased bait, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedBait($purchased_bait) + { + if (is_null($purchased_bait)) { + throw new \InvalidArgumentException('non-nullable purchased_bait cannot be null'); + } + $this->container['purchased_bait'] = $purchased_bait; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets commercial_flights + * + * @return float + */ + public function getCommercialFlights() + { + return $this->container['commercial_flights']; + } + + /** + * Sets commercial_flights + * + * @param float $commercial_flights Emissions from commercial flights, in tonnes-CO2e + * + * @return self + */ + public function setCommercialFlights($commercial_flights) + { + if (is_null($commercial_flights)) { + throw new \InvalidArgumentException('non-nullable commercial_flights cannot be null'); + } + $this->container['commercial_flights'] = $commercial_flights; + + return $this; + } + + /** + * Gets inbound_freight + * + * @return float + */ + public function getInboundFreight() + { + return $this->container['inbound_freight']; + } + + /** + * Sets inbound_freight + * + * @param float $inbound_freight Emissions from inbound freight, in tonnes-CO2e + * + * @return self + */ + public function setInboundFreight($inbound_freight) + { + if (is_null($inbound_freight)) { + throw new \InvalidArgumentException('non-nullable inbound_freight cannot be null'); + } + $this->container['inbound_freight'] = $inbound_freight; + + return $this; + } + + /** + * Gets outbound_freight + * + * @return float + */ + public function getOutboundFreight() + { + return $this->container['outbound_freight']; + } + + /** + * Sets outbound_freight + * + * @param float $outbound_freight Emissions from outbound freight, in tonnes-CO2e + * + * @return self + */ + public function setOutboundFreight($outbound_freight) + { + if (is_null($outbound_freight)) { + throw new \InvalidArgumentException('non-nullable outbound_freight cannot be null'); + } + $this->container['outbound_freight'] = $outbound_freight; + + return $this; + } + + /** + * Gets solid_waste_sent_offsite + * + * @return float + */ + public function getSolidWasteSentOffsite() + { + return $this->container['solid_waste_sent_offsite']; + } + + /** + * Sets solid_waste_sent_offsite + * + * @param float $solid_waste_sent_offsite Emissions from solid waste sent offsite, in tonnes-CO2e + * + * @return self + */ + public function setSolidWasteSentOffsite($solid_waste_sent_offsite) + { + if (is_null($solid_waste_sent_offsite)) { + throw new \InvalidArgumentException('non-nullable solid_waste_sent_offsite cannot be null'); + } + $this->container['solid_waste_sent_offsite'] = $solid_waste_sent_offsite; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequest.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequest.php new file mode 100644 index 00000000..ffd54125 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequest.php @@ -0,0 +1,414 @@ + + */ +class PostAquacultureRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'enterprises' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'enterprises' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'enterprises' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'enterprises' => 'enterprises' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'enterprises' => 'setEnterprises' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'enterprises' => 'getEnterprises' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('enterprises', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['enterprises'] === null) { + $invalidProperties[] = "'enterprises' 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 enterprises + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInner[] + */ + public function getEnterprises() + { + return $this->container['enterprises']; + } + + /** + * Sets enterprises + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInner[] $enterprises enterprises + * + * @return self + */ + public function setEnterprises($enterprises) + { + if (is_null($enterprises)) { + throw new \InvalidArgumentException('non-nullable enterprises cannot be null'); + } + $this->container['enterprises'] = $enterprises; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInner.php new file mode 100644 index 00000000..a0db1a62 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInner.php @@ -0,0 +1,1148 @@ + + */ +class PostAquacultureRequestEnterprisesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'production_system' => 'string', + 'total_harvest_kg' => 'float', + 'refrigerants' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerRefrigerantsInner[]', + 'bait' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerBaitInner[]', + 'custom_bait' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[]', + 'inbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'outbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'total_commercial_flights_km' => 'float', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'electricity_source' => 'string', + 'fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel', + 'fluid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[]', + 'solid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste', + 'carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'production_system' => null, + 'total_harvest_kg' => null, + 'refrigerants' => null, + 'bait' => null, + 'custom_bait' => null, + 'inbound_freight' => null, + 'outbound_freight' => null, + 'total_commercial_flights_km' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'electricity_source' => null, + 'fuel' => null, + 'fluid_waste' => null, + 'solid_waste' => null, + 'carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'production_system' => false, + 'total_harvest_kg' => false, + 'refrigerants' => false, + 'bait' => false, + 'custom_bait' => false, + 'inbound_freight' => false, + 'outbound_freight' => false, + 'total_commercial_flights_km' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'electricity_source' => false, + 'fuel' => false, + 'fluid_waste' => false, + 'solid_waste' => false, + 'carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'production_system' => 'productionSystem', + 'total_harvest_kg' => 'totalHarvestKg', + 'refrigerants' => 'refrigerants', + 'bait' => 'bait', + 'custom_bait' => 'customBait', + 'inbound_freight' => 'inboundFreight', + 'outbound_freight' => 'outboundFreight', + 'total_commercial_flights_km' => 'totalCommercialFlightsKm', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'electricity_source' => 'electricitySource', + 'fuel' => 'fuel', + 'fluid_waste' => 'fluidWaste', + 'solid_waste' => 'solidWaste', + 'carbon_offsets' => 'carbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'production_system' => 'setProductionSystem', + 'total_harvest_kg' => 'setTotalHarvestKg', + 'refrigerants' => 'setRefrigerants', + 'bait' => 'setBait', + 'custom_bait' => 'setCustomBait', + 'inbound_freight' => 'setInboundFreight', + 'outbound_freight' => 'setOutboundFreight', + 'total_commercial_flights_km' => 'setTotalCommercialFlightsKm', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'electricity_source' => 'setElectricitySource', + 'fuel' => 'setFuel', + 'fluid_waste' => 'setFluidWaste', + 'solid_waste' => 'setSolidWaste', + 'carbon_offsets' => 'setCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'production_system' => 'getProductionSystem', + 'total_harvest_kg' => 'getTotalHarvestKg', + 'refrigerants' => 'getRefrigerants', + 'bait' => 'getBait', + 'custom_bait' => 'getCustomBait', + 'inbound_freight' => 'getInboundFreight', + 'outbound_freight' => 'getOutboundFreight', + 'total_commercial_flights_km' => 'getTotalCommercialFlightsKm', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'electricity_source' => 'getElectricitySource', + 'fuel' => 'getFuel', + 'fluid_waste' => 'getFluidWaste', + 'solid_waste' => 'getSolidWaste', + 'carbon_offsets' => 'getCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const PRODUCTION_SYSTEM_ABALONE_FARMING = 'Abalone Farming'; + public const PRODUCTION_SYSTEM_MUSSEL_FARMING = 'Mussel Farming'; + public const PRODUCTION_SYSTEM_OFFSHORE_CAGED_AQUACULTURE = 'Offshore Caged Aquaculture'; + public const PRODUCTION_SYSTEM_ONLAND_FISH_FARMING = 'Onland Fish Farming'; + public const PRODUCTION_SYSTEM_ONSHORE_HATCHERY = 'Onshore Hatchery'; + public const PRODUCTION_SYSTEM_OTHER = 'Other'; + public const PRODUCTION_SYSTEM_OYSTER_FARMING = 'Oyster Farming'; + public const PRODUCTION_SYSTEM_PEARL_FARMING = 'Pearl Farming'; + public const PRODUCTION_SYSTEM_PRAWN_FARMING = 'Prawn Farming'; + public const PRODUCTION_SYSTEM_SEAWEED_AND_MACROALGAE_FARMING = 'Seaweed and Macroalgae Farming'; + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductionSystemAllowableValues() + { + return [ + self::PRODUCTION_SYSTEM_ABALONE_FARMING, + self::PRODUCTION_SYSTEM_MUSSEL_FARMING, + self::PRODUCTION_SYSTEM_OFFSHORE_CAGED_AQUACULTURE, + self::PRODUCTION_SYSTEM_ONLAND_FISH_FARMING, + self::PRODUCTION_SYSTEM_ONSHORE_HATCHERY, + self::PRODUCTION_SYSTEM_OTHER, + self::PRODUCTION_SYSTEM_OYSTER_FARMING, + self::PRODUCTION_SYSTEM_PEARL_FARMING, + self::PRODUCTION_SYSTEM_PRAWN_FARMING, + self::PRODUCTION_SYSTEM_SEAWEED_AND_MACROALGAE_FARMING, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('production_system', $data ?? [], null); + $this->setIfExists('total_harvest_kg', $data ?? [], null); + $this->setIfExists('refrigerants', $data ?? [], null); + $this->setIfExists('bait', $data ?? [], null); + $this->setIfExists('custom_bait', $data ?? [], null); + $this->setIfExists('inbound_freight', $data ?? [], null); + $this->setIfExists('outbound_freight', $data ?? [], null); + $this->setIfExists('total_commercial_flights_km', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('fluid_waste', $data ?? [], null); + $this->setIfExists('solid_waste', $data ?? [], null); + $this->setIfExists('carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['production_system'] === null) { + $invalidProperties[] = "'production_system' can't be null"; + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!is_null($this->container['production_system']) && !in_array($this->container['production_system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'production_system', must be one of '%s'", + $this->container['production_system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['total_harvest_kg'] === null) { + $invalidProperties[] = "'total_harvest_kg' can't be null"; + } + if ($this->container['refrigerants'] === null) { + $invalidProperties[] = "'refrigerants' can't be null"; + } + if ($this->container['bait'] === null) { + $invalidProperties[] = "'bait' can't be null"; + } + if ($this->container['custom_bait'] === null) { + $invalidProperties[] = "'custom_bait' can't be null"; + } + if ($this->container['inbound_freight'] === null) { + $invalidProperties[] = "'inbound_freight' can't be null"; + } + if ($this->container['outbound_freight'] === null) { + $invalidProperties[] = "'outbound_freight' can't be null"; + } + if ($this->container['total_commercial_flights_km'] === null) { + $invalidProperties[] = "'total_commercial_flights_km' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['fluid_waste'] === null) { + $invalidProperties[] = "'fluid_waste' can't be null"; + } + if ($this->container['solid_waste'] === null) { + $invalidProperties[] = "'solid_waste' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets production_system + * + * @return string + */ + public function getProductionSystem() + { + return $this->container['production_system']; + } + + /** + * Sets production_system + * + * @param string $production_system Production system of the aquaculture enterprise + * + * @return self + */ + public function setProductionSystem($production_system) + { + if (is_null($production_system)) { + throw new \InvalidArgumentException('non-nullable production_system cannot be null'); + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!in_array($production_system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'production_system', must be one of '%s'", + $production_system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['production_system'] = $production_system; + + return $this; + } + + /** + * Gets total_harvest_kg + * + * @return float + */ + public function getTotalHarvestKg() + { + return $this->container['total_harvest_kg']; + } + + /** + * Sets total_harvest_kg + * + * @param float $total_harvest_kg Total harvest in kg + * + * @return self + */ + public function setTotalHarvestKg($total_harvest_kg) + { + if (is_null($total_harvest_kg)) { + throw new \InvalidArgumentException('non-nullable total_harvest_kg cannot be null'); + } + $this->container['total_harvest_kg'] = $total_harvest_kg; + + return $this; + } + + /** + * Gets refrigerants + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerRefrigerantsInner[] + */ + public function getRefrigerants() + { + return $this->container['refrigerants']; + } + + /** + * Sets refrigerants + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerRefrigerantsInner[] $refrigerants Refrigerant type + * + * @return self + */ + public function setRefrigerants($refrigerants) + { + if (is_null($refrigerants)) { + throw new \InvalidArgumentException('non-nullable refrigerants cannot be null'); + } + $this->container['refrigerants'] = $refrigerants; + + return $this; + } + + /** + * Gets bait + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerBaitInner[] + */ + public function getBait() + { + return $this->container['bait']; + } + + /** + * Sets bait + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerBaitInner[] $bait Bait purchases + * + * @return self + */ + public function setBait($bait) + { + if (is_null($bait)) { + throw new \InvalidArgumentException('non-nullable bait cannot be null'); + } + $this->container['bait'] = $bait; + + return $this; + } + + /** + * Gets custom_bait + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[] + */ + public function getCustomBait() + { + return $this->container['custom_bait']; + } + + /** + * Sets custom_bait + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[] $custom_bait Custom bait purchases + * + * @return self + */ + public function setCustomBait($custom_bait) + { + if (is_null($custom_bait)) { + throw new \InvalidArgumentException('non-nullable custom_bait cannot be null'); + } + $this->container['custom_bait'] = $custom_bait; + + return $this; + } + + /** + * Gets inbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getInboundFreight() + { + return $this->container['inbound_freight']; + } + + /** + * Sets inbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $inbound_freight Services used to transport goods to the enterprise + * + * @return self + */ + public function setInboundFreight($inbound_freight) + { + if (is_null($inbound_freight)) { + throw new \InvalidArgumentException('non-nullable inbound_freight cannot be null'); + } + $this->container['inbound_freight'] = $inbound_freight; + + return $this; + } + + /** + * Gets outbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getOutboundFreight() + { + return $this->container['outbound_freight']; + } + + /** + * Sets outbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $outbound_freight Services used to transport goods from the enterprise + * + * @return self + */ + public function setOutboundFreight($outbound_freight) + { + if (is_null($outbound_freight)) { + throw new \InvalidArgumentException('non-nullable outbound_freight cannot be null'); + } + $this->container['outbound_freight'] = $outbound_freight; + + return $this; + } + + /** + * Gets total_commercial_flights_km + * + * @return float + */ + public function getTotalCommercialFlightsKm() + { + return $this->container['total_commercial_flights_km']; + } + + /** + * Sets total_commercial_flights_km + * + * @param float $total_commercial_flights_km Total distance of commercial flights, in km (kilometers) + * + * @return self + */ + public function setTotalCommercialFlightsKm($total_commercial_flights_km) + { + if (is_null($total_commercial_flights_km)) { + throw new \InvalidArgumentException('non-nullable total_commercial_flights_km cannot be null'); + } + $this->container['total_commercial_flights_km'] = $total_commercial_flights_km; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostAquacultureRequestEnterprisesInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostAquacultureRequestEnterprisesInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel $fuel fuel + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets fluid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] + */ + public function getFluidWaste() + { + return $this->container['fluid_waste']; + } + + /** + * Sets fluid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] $fluid_waste Amount of fluid waste, in kL (kilolitres) + * + * @return self + */ + public function setFluidWaste($fluid_waste) + { + if (is_null($fluid_waste)) { + throw new \InvalidArgumentException('non-nullable fluid_waste cannot be null'); + } + $this->container['fluid_waste'] = $fluid_waste; + + return $this; + } + + /** + * Gets solid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste + */ + public function getSolidWaste() + { + return $this->container['solid_waste']; + } + + /** + * Sets solid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste $solid_waste solid_waste + * + * @return self + */ + public function setSolidWaste($solid_waste) + { + if (is_null($solid_waste)) { + throw new \InvalidArgumentException('non-nullable solid_waste cannot be null'); + } + $this->container['solid_waste'] = $solid_waste; + + return $this; + } + + /** + * Gets carbon_offsets + * + * @return float|null + */ + public function getCarbonOffsets() + { + return $this->container['carbon_offsets']; + } + + /** + * Sets carbon_offsets + * + * @param float|null $carbon_offsets Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0) + * + * @return self + */ + public function setCarbonOffsets($carbon_offsets) + { + if (is_null($carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable carbon_offsets cannot be null'); + } + $this->container['carbon_offsets'] = $carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerBaitInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerBaitInner.php new file mode 100644 index 00000000..a17fc898 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerBaitInner.php @@ -0,0 +1,582 @@ + + */ +class PostAquacultureRequestEnterprisesInnerBaitInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_bait_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'purchased_tonnes' => 'float', + 'additional_ingredients' => 'float', + 'emissions_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'purchased_tonnes' => null, + 'additional_ingredients' => null, + 'emissions_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'purchased_tonnes' => false, + 'additional_ingredients' => false, + 'emissions_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'purchased_tonnes' => 'purchasedTonnes', + 'additional_ingredients' => 'additionalIngredients', + 'emissions_intensity' => 'emissionsIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'purchased_tonnes' => 'setPurchasedTonnes', + 'additional_ingredients' => 'setAdditionalIngredients', + 'emissions_intensity' => 'setEmissionsIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'purchased_tonnes' => 'getPurchasedTonnes', + 'additional_ingredients' => 'getAdditionalIngredients', + 'emissions_intensity' => 'getEmissionsIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_WHOLE_SARDINES = 'Whole Sardines'; + public const TYPE_LOW_ANIMAL_PROTEIN_FORMULATED_FEED = 'Low Animal Protein Formulated Feed'; + public const TYPE_HIGH_ANIMAL_PROTEIN_FORMULATED_FEED = 'High Animal Protein Formulated Feed'; + public const TYPE_CEREAL_GRAIN = 'Cereal Grain'; + public const TYPE_SQUID = 'Squid'; + public const TYPE_WHOLE_FISH = 'Whole Fish'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_WHOLE_SARDINES, + self::TYPE_LOW_ANIMAL_PROTEIN_FORMULATED_FEED, + self::TYPE_HIGH_ANIMAL_PROTEIN_FORMULATED_FEED, + self::TYPE_CEREAL_GRAIN, + self::TYPE_SQUID, + self::TYPE_WHOLE_FISH, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('purchased_tonnes', $data ?? [], null); + $this->setIfExists('additional_ingredients', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], 0); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['purchased_tonnes'] === null) { + $invalidProperties[] = "'purchased_tonnes' can't be null"; + } + if ($this->container['additional_ingredients'] === null) { + $invalidProperties[] = "'additional_ingredients' can't be null"; + } + if (($this->container['additional_ingredients'] > 1)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be smaller than or equal to 1."; + } + + if (($this->container['additional_ingredients'] < 0)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be bigger than or equal to 0."; + } + + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Bait product type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets purchased_tonnes + * + * @return float + */ + public function getPurchasedTonnes() + { + return $this->container['purchased_tonnes']; + } + + /** + * Sets purchased_tonnes + * + * @param float $purchased_tonnes Purchased product in tonnes + * + * @return self + */ + public function setPurchasedTonnes($purchased_tonnes) + { + if (is_null($purchased_tonnes)) { + throw new \InvalidArgumentException('non-nullable purchased_tonnes cannot be null'); + } + $this->container['purchased_tonnes'] = $purchased_tonnes; + + return $this; + } + + /** + * Gets additional_ingredients + * + * @return float + */ + public function getAdditionalIngredients() + { + return $this->container['additional_ingredients']; + } + + /** + * Sets additional_ingredients + * + * @param float $additional_ingredients Additional ingredient fraction, from 0 to 1 + * + * @return self + */ + public function setAdditionalIngredients($additional_ingredients) + { + if (is_null($additional_ingredients)) { + throw new \InvalidArgumentException('non-nullable additional_ingredients cannot be null'); + } + + if (($additional_ingredients > 1)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostAquacultureRequestEnterprisesInnerBaitInner., must be smaller than or equal to 1.'); + } + if (($additional_ingredients < 0)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostAquacultureRequestEnterprisesInnerBaitInner., must be bigger than or equal to 0.'); + } + + $this->container['additional_ingredients'] = $additional_ingredients; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of additional ingredients, in kg CO2e/kg bait (default 0) + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerCustomBaitInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerCustomBaitInner.php new file mode 100644 index 00000000..7c231b75 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerCustomBaitInner.php @@ -0,0 +1,450 @@ + + */ +class PostAquacultureRequestEnterprisesInnerCustomBaitInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_customBait_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'purchased_tonnes' => 'float', + 'emissions_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'purchased_tonnes' => null, + 'emissions_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'purchased_tonnes' => false, + 'emissions_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'purchased_tonnes' => 'purchasedTonnes', + 'emissions_intensity' => 'emissionsIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'purchased_tonnes' => 'setPurchasedTonnes', + 'emissions_intensity' => 'setEmissionsIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'purchased_tonnes' => 'getPurchasedTonnes', + 'emissions_intensity' => 'getEmissionsIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('purchased_tonnes', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['purchased_tonnes'] === null) { + $invalidProperties[] = "'purchased_tonnes' can't be null"; + } + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' 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 purchased_tonnes + * + * @return float + */ + public function getPurchasedTonnes() + { + return $this->container['purchased_tonnes']; + } + + /** + * Sets purchased_tonnes + * + * @param float $purchased_tonnes Purchased product in tonnes + * + * @return self + */ + public function setPurchasedTonnes($purchased_tonnes) + { + if (is_null($purchased_tonnes)) { + throw new \InvalidArgumentException('non-nullable purchased_tonnes cannot be null'); + } + $this->container['purchased_tonnes'] = $purchased_tonnes; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of product, in kg CO2e/kg bait + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFluidWasteInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFluidWasteInner.php new file mode 100644 index 00000000..382f63c5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFluidWasteInner.php @@ -0,0 +1,601 @@ + + */ +class PostAquacultureRequestEnterprisesInnerFluidWasteInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_fluidWaste_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fluid_waste_kl' => 'float', + 'fluid_waste_treatment_type' => 'string', + 'average_inlet_cod' => 'float', + 'average_outlet_cod' => 'float', + 'flared_combusted_fraction' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fluid_waste_kl' => null, + 'fluid_waste_treatment_type' => null, + 'average_inlet_cod' => null, + 'average_outlet_cod' => null, + 'flared_combusted_fraction' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fluid_waste_kl' => false, + 'fluid_waste_treatment_type' => false, + 'average_inlet_cod' => false, + 'average_outlet_cod' => false, + 'flared_combusted_fraction' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'fluid_waste_kl' => 'fluidWasteKl', + 'fluid_waste_treatment_type' => 'fluidWasteTreatmentType', + 'average_inlet_cod' => 'averageInletCOD', + 'average_outlet_cod' => 'averageOutletCOD', + 'flared_combusted_fraction' => 'flaredCombustedFraction' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fluid_waste_kl' => 'setFluidWasteKl', + 'fluid_waste_treatment_type' => 'setFluidWasteTreatmentType', + 'average_inlet_cod' => 'setAverageInletCod', + 'average_outlet_cod' => 'setAverageOutletCod', + 'flared_combusted_fraction' => 'setFlaredCombustedFraction' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fluid_waste_kl' => 'getFluidWasteKl', + 'fluid_waste_treatment_type' => 'getFluidWasteTreatmentType', + 'average_inlet_cod' => 'getAverageInletCod', + 'average_outlet_cod' => 'getAverageOutletCod', + 'flared_combusted_fraction' => 'getFlaredCombustedFraction' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const FLUID_WASTE_TREATMENT_TYPE_MANAGED_AEROBIC = 'Managed Aerobic'; + public const FLUID_WASTE_TREATMENT_TYPE_UNMANAGED_AEROBIC = 'Unmanaged Aerobic'; + public const FLUID_WASTE_TREATMENT_TYPE_ANAEROBIC_DIGESTER_REACTOR = 'Anaerobic Digester/Reactor'; + public const FLUID_WASTE_TREATMENT_TYPE_SHALLOW_ANAEROBIC_LAGOON_2M = 'Shallow Anaerobic Lagoon <2m'; + public const FLUID_WASTE_TREATMENT_TYPE_DEEP_ANAEROBIC_LAGOON_2M = 'Deep Anaerobic Lagoon >2m'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getFluidWasteTreatmentTypeAllowableValues() + { + return [ + self::FLUID_WASTE_TREATMENT_TYPE_MANAGED_AEROBIC, + self::FLUID_WASTE_TREATMENT_TYPE_UNMANAGED_AEROBIC, + self::FLUID_WASTE_TREATMENT_TYPE_ANAEROBIC_DIGESTER_REACTOR, + self::FLUID_WASTE_TREATMENT_TYPE_SHALLOW_ANAEROBIC_LAGOON_2M, + self::FLUID_WASTE_TREATMENT_TYPE_DEEP_ANAEROBIC_LAGOON_2M, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fluid_waste_kl', $data ?? [], null); + $this->setIfExists('fluid_waste_treatment_type', $data ?? [], null); + $this->setIfExists('average_inlet_cod', $data ?? [], null); + $this->setIfExists('average_outlet_cod', $data ?? [], null); + $this->setIfExists('flared_combusted_fraction', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['fluid_waste_kl'] === null) { + $invalidProperties[] = "'fluid_waste_kl' can't be null"; + } + if ($this->container['fluid_waste_treatment_type'] === null) { + $invalidProperties[] = "'fluid_waste_treatment_type' can't be null"; + } + $allowedValues = $this->getFluidWasteTreatmentTypeAllowableValues(); + if (!is_null($this->container['fluid_waste_treatment_type']) && !in_array($this->container['fluid_waste_treatment_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'fluid_waste_treatment_type', must be one of '%s'", + $this->container['fluid_waste_treatment_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_inlet_cod'] === null) { + $invalidProperties[] = "'average_inlet_cod' can't be null"; + } + if ($this->container['average_outlet_cod'] === null) { + $invalidProperties[] = "'average_outlet_cod' can't be null"; + } + if ($this->container['flared_combusted_fraction'] === null) { + $invalidProperties[] = "'flared_combusted_fraction' 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 fluid_waste_kl + * + * @return float + */ + public function getFluidWasteKl() + { + return $this->container['fluid_waste_kl']; + } + + /** + * Sets fluid_waste_kl + * + * @param float $fluid_waste_kl Amount of fluid waste, in kL (kilolitres) + * + * @return self + */ + public function setFluidWasteKl($fluid_waste_kl) + { + if (is_null($fluid_waste_kl)) { + throw new \InvalidArgumentException('non-nullable fluid_waste_kl cannot be null'); + } + $this->container['fluid_waste_kl'] = $fluid_waste_kl; + + return $this; + } + + /** + * Gets fluid_waste_treatment_type + * + * @return string + */ + public function getFluidWasteTreatmentType() + { + return $this->container['fluid_waste_treatment_type']; + } + + /** + * Sets fluid_waste_treatment_type + * + * @param string $fluid_waste_treatment_type Type of fluid waste treatment + * + * @return self + */ + public function setFluidWasteTreatmentType($fluid_waste_treatment_type) + { + if (is_null($fluid_waste_treatment_type)) { + throw new \InvalidArgumentException('non-nullable fluid_waste_treatment_type cannot be null'); + } + $allowedValues = $this->getFluidWasteTreatmentTypeAllowableValues(); + if (!in_array($fluid_waste_treatment_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'fluid_waste_treatment_type', must be one of '%s'", + $fluid_waste_treatment_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['fluid_waste_treatment_type'] = $fluid_waste_treatment_type; + + return $this; + } + + /** + * Gets average_inlet_cod + * + * @return float + */ + public function getAverageInletCod() + { + return $this->container['average_inlet_cod']; + } + + /** + * Sets average_inlet_cod + * + * @param float $average_inlet_cod Average inlet COD (mg per litre) + * + * @return self + */ + public function setAverageInletCod($average_inlet_cod) + { + if (is_null($average_inlet_cod)) { + throw new \InvalidArgumentException('non-nullable average_inlet_cod cannot be null'); + } + $this->container['average_inlet_cod'] = $average_inlet_cod; + + return $this; + } + + /** + * Gets average_outlet_cod + * + * @return float + */ + public function getAverageOutletCod() + { + return $this->container['average_outlet_cod']; + } + + /** + * Sets average_outlet_cod + * + * @param float $average_outlet_cod Average outlet COD (mg per litre) + * + * @return self + */ + public function setAverageOutletCod($average_outlet_cod) + { + if (is_null($average_outlet_cod)) { + throw new \InvalidArgumentException('non-nullable average_outlet_cod cannot be null'); + } + $this->container['average_outlet_cod'] = $average_outlet_cod; + + return $this; + } + + /** + * Gets flared_combusted_fraction + * + * @return float + */ + public function getFlaredCombustedFraction() + { + return $this->container['flared_combusted_fraction']; + } + + /** + * Sets flared_combusted_fraction + * + * @param float $flared_combusted_fraction Fraction of waste flared or combusted, between 0 and 1 + * + * @return self + */ + public function setFlaredCombustedFraction($flared_combusted_fraction) + { + if (is_null($flared_combusted_fraction)) { + throw new \InvalidArgumentException('non-nullable flared_combusted_fraction cannot be null'); + } + $this->container['flared_combusted_fraction'] = $flared_combusted_fraction; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuel.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuel.php new file mode 100644 index 00000000..69f5a15d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuel.php @@ -0,0 +1,488 @@ + + */ +class PostAquacultureRequestEnterprisesInnerFuel implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_fuel'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'transport_fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner[]', + 'stationary_fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner[]', + 'natural_gas' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'transport_fuel' => null, + 'stationary_fuel' => null, + 'natural_gas' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'transport_fuel' => false, + 'stationary_fuel' => false, + 'natural_gas' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'transport_fuel' => 'transportFuel', + 'stationary_fuel' => 'stationaryFuel', + 'natural_gas' => 'naturalGas' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'transport_fuel' => 'setTransportFuel', + 'stationary_fuel' => 'setStationaryFuel', + 'natural_gas' => 'setNaturalGas' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'transport_fuel' => 'getTransportFuel', + 'stationary_fuel' => 'getStationaryFuel', + 'natural_gas' => 'getNaturalGas' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('transport_fuel', $data ?? [], null); + $this->setIfExists('stationary_fuel', $data ?? [], null); + $this->setIfExists('natural_gas', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['transport_fuel'] === null) { + $invalidProperties[] = "'transport_fuel' can't be null"; + } + if ($this->container['stationary_fuel'] === null) { + $invalidProperties[] = "'stationary_fuel' can't be null"; + } + if ($this->container['natural_gas'] === null) { + $invalidProperties[] = "'natural_gas' 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 transport_fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner[] + */ + public function getTransportFuel() + { + return $this->container['transport_fuel']; + } + + /** + * Sets transport_fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner[] $transport_fuel A list of fuels used in transportation and vehicles + * + * @return self + */ + public function setTransportFuel($transport_fuel) + { + if (is_null($transport_fuel)) { + throw new \InvalidArgumentException('non-nullable transport_fuel cannot be null'); + } + $this->container['transport_fuel'] = $transport_fuel; + + return $this; + } + + /** + * Gets stationary_fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner[] + */ + public function getStationaryFuel() + { + return $this->container['stationary_fuel']; + } + + /** + * Sets stationary_fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner[] $stationary_fuel A list of fuels used in stationary applications + * + * @return self + */ + public function setStationaryFuel($stationary_fuel) + { + if (is_null($stationary_fuel)) { + throw new \InvalidArgumentException('non-nullable stationary_fuel cannot be null'); + } + $this->container['stationary_fuel'] = $stationary_fuel; + + return $this; + } + + /** + * Gets natural_gas + * + * @return float + */ + public function getNaturalGas() + { + return $this->container['natural_gas']; + } + + /** + * Sets natural_gas + * + * @param float $natural_gas Amount of natural gas consumed in Mj (megajoules) + * + * @return self + */ + public function setNaturalGas($natural_gas) + { + if (is_null($natural_gas)) { + throw new \InvalidArgumentException('non-nullable natural_gas cannot be null'); + } + $this->container['natural_gas'] = $natural_gas; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.php new file mode 100644 index 00000000..dd35e6e0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.php @@ -0,0 +1,496 @@ + + */ +class PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_fuel_stationaryFuel_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'amount_litres' => '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_litres' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'amount_litres' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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_litres' => 'amountLitres' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'amount_litres' => 'setAmountLitres' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'amount_litres' => 'getAmountLitres' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PETROL = 'petrol'; + public const TYPE_DIESEL = 'diesel'; + public const TYPE_LPG = 'lpg'; + public const TYPE_ETHANOL = 'ethanol'; + public const TYPE_BIODIESEL = 'biodiesel'; + public const TYPE_RENEWABLE_DIESEL = 'renewable diesel'; + public const TYPE_OTHER_BIOFUELS = 'other biofuels'; + public const TYPE_LNG = 'lng'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PETROL, + self::TYPE_DIESEL, + self::TYPE_LPG, + self::TYPE_ETHANOL, + self::TYPE_BIODIESEL, + self::TYPE_RENEWABLE_DIESEL, + self::TYPE_OTHER_BIOFUELS, + self::TYPE_LNG, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('amount_litres', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['amount_litres'] === null) { + $invalidProperties[] = "'amount_litres' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Type of fuel + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets amount_litres + * + * @return float + */ + public function getAmountLitres() + { + return $this->container['amount_litres']; + } + + /** + * Sets amount_litres + * + * @param float $amount_litres Amount of fuel consumed (litres) + * + * @return self + */ + public function setAmountLitres($amount_litres) + { + if (is_null($amount_litres)) { + throw new \InvalidArgumentException('non-nullable amount_litres cannot be null'); + } + $this->container['amount_litres'] = $amount_litres; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.php new file mode 100644 index 00000000..d9341d73 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.php @@ -0,0 +1,504 @@ + + */ +class PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_fuel_transportFuel_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'amount_litres' => '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_litres' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'amount_litres' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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_litres' => 'amountLitres' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'amount_litres' => 'setAmountLitres' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'amount_litres' => 'getAmountLitres' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PETROL = 'petrol'; + public const TYPE_DIESEL = 'diesel'; + public const TYPE_LPG = 'lpg'; + public const TYPE_ETHANOL = 'ethanol'; + public const TYPE_BIODIESEL = 'biodiesel'; + public const TYPE_RENEWABLE_DIESEL = 'renewable diesel'; + public const TYPE_OTHER_BIOFUELS = 'other biofuels'; + public const TYPE_LNG = 'lng'; + public const TYPE_FUEL_OIL = 'fuel oil'; + public const TYPE_AVGAS = 'avgas'; + public const TYPE_JET_A_1 = 'jet a-1'; + public const TYPE_JET_B = 'jet b'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PETROL, + self::TYPE_DIESEL, + self::TYPE_LPG, + self::TYPE_ETHANOL, + self::TYPE_BIODIESEL, + self::TYPE_RENEWABLE_DIESEL, + self::TYPE_OTHER_BIOFUELS, + self::TYPE_LNG, + self::TYPE_FUEL_OIL, + self::TYPE_AVGAS, + self::TYPE_JET_A_1, + self::TYPE_JET_B, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('amount_litres', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['amount_litres'] === null) { + $invalidProperties[] = "'amount_litres' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Type of fuel + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets amount_litres + * + * @return float + */ + public function getAmountLitres() + { + return $this->container['amount_litres']; + } + + /** + * Sets amount_litres + * + * @param float $amount_litres Amount of fuel consumed (litres) + * + * @return self + */ + public function setAmountLitres($amount_litres) + { + if (is_null($amount_litres)) { + throw new \InvalidArgumentException('non-nullable amount_litres cannot be null'); + } + $this->container['amount_litres'] = $amount_litres; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerInboundFreightInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerInboundFreightInner.php new file mode 100644 index 00000000..5e56c621 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerInboundFreightInner.php @@ -0,0 +1,492 @@ + + */ +class PostAquacultureRequestEnterprisesInnerInboundFreightInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_inboundFreight_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'total_km_tonnes' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'total_km_tonnes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'total_km_tonnes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'total_km_tonnes' => 'totalKmTonnes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'total_km_tonnes' => 'setTotalKmTonnes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'total_km_tonnes' => 'getTotalKmTonnes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_TRUCK = 'Truck'; + public const TYPE_RAIL = 'Rail'; + public const TYPE_LONG_HAUL_FLIGHT = 'Long haul flight'; + public const TYPE_MEDIUM_HAUL_FLIGHT = 'Medium haul flight'; + public const TYPE_SMALL_CONTAINER_SHIP = 'Small container ship'; + public const TYPE_LARGE_CONTAINER_SHIP = 'Large container ship'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_TRUCK, + self::TYPE_RAIL, + self::TYPE_LONG_HAUL_FLIGHT, + self::TYPE_MEDIUM_HAUL_FLIGHT, + self::TYPE_SMALL_CONTAINER_SHIP, + self::TYPE_LARGE_CONTAINER_SHIP, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('total_km_tonnes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['total_km_tonnes'] === null) { + $invalidProperties[] = "'total_km_tonnes' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Type of freight used + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets total_km_tonnes + * + * @return float + */ + public function getTotalKmTonnes() + { + return $this->container['total_km_tonnes']; + } + + /** + * Sets total_km_tonnes + * + * @param float $total_km_tonnes Total distance of freight, in kilometre tonnes + * + * @return self + */ + public function setTotalKmTonnes($total_km_tonnes) + { + if (is_null($total_km_tonnes)) { + throw new \InvalidArgumentException('non-nullable total_km_tonnes cannot be null'); + } + $this->container['total_km_tonnes'] = $total_km_tonnes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.php new file mode 100644 index 00000000..03b32b5a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.php @@ -0,0 +1,666 @@ + + */ +class PostAquacultureRequestEnterprisesInnerRefrigerantsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_refrigerants_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'refrigerant' => 'string', + 'charge_size' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'refrigerant' => null, + 'charge_size' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'refrigerant' => false, + 'charge_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 = [ + 'refrigerant' => 'refrigerant', + 'charge_size' => 'chargeSize' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'refrigerant' => 'setRefrigerant', + 'charge_size' => 'setChargeSize' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'refrigerant' => 'getRefrigerant', + 'charge_size' => 'getChargeSize' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const REFRIGERANT_HFC_23 = 'HFC-23'; + public const REFRIGERANT_HFC_32 = 'HFC-32'; + public const REFRIGERANT_HFC_41 = 'HFC-41'; + public const REFRIGERANT_HFC_43_10MEE = 'HFC-43-10mee'; + public const REFRIGERANT_HFC_125 = 'HFC-125'; + public const REFRIGERANT_HFC_134 = 'HFC-134'; + public const REFRIGERANT_HFC_134A = 'HFC-134a'; + public const REFRIGERANT_HFC_143 = 'HFC-143'; + public const REFRIGERANT_HFC_143A = 'HFC-143a'; + public const REFRIGERANT_HFC_152A = 'HFC-152a'; + public const REFRIGERANT_HFC_227EA = 'HFC-227ea'; + public const REFRIGERANT_HFC_236FA = 'HFC-236fa'; + public const REFRIGERANT_HFC_245CA = 'HFC-245ca'; + public const REFRIGERANT_HFC_245FA = 'HFC-245fa'; + public const REFRIGERANT_HFC_365MFC = 'HFC-365mfc'; + public const REFRIGERANT_R438_A = 'R438A'; + public const REFRIGERANT_R448_A = 'R448A'; + public const REFRIGERANT_R_22 = 'R-22'; + public const REFRIGERANT_AMMONIA__R_717 = 'Ammonia (R-717)'; + public const REFRIGERANT_R_11 = 'R-11'; + public const REFRIGERANT_R_12 = 'R-12'; + public const REFRIGERANT_R_13 = 'R-13'; + public const REFRIGERANT_R_23 = 'R-23'; + public const REFRIGERANT_R_32 = 'R-32'; + public const REFRIGERANT_R_113 = 'R-113'; + public const REFRIGERANT_R_114 = 'R-114'; + public const REFRIGERANT_R_115 = 'R-115'; + public const REFRIGERANT_R_116 = 'R-116'; + public const REFRIGERANT_R_123 = 'R-123'; + public const REFRIGERANT_R_124 = 'R-124'; + public const REFRIGERANT_R_125 = 'R-125'; + public const REFRIGERANT_R_134A = 'R-134a'; + public const REFRIGERANT_R_141B = 'R-141b'; + public const REFRIGERANT_R_142B = 'R-142b'; + public const REFRIGERANT_R_143A = 'R-143a'; + public const REFRIGERANT_R_152A = 'R-152a'; + public const REFRIGERANT_R_218 = 'R-218'; + public const REFRIGERANT_R_227EA = 'R-227ea'; + public const REFRIGERANT_R_236FA = 'R-236fa'; + public const REFRIGERANT_R_245CA = 'R-245ca'; + public const REFRIGERANT_R_245FA = 'R-245fa'; + public const REFRIGERANT_R_C318 = 'R-C318'; + public const REFRIGERANT_R_401_A = 'R-401A'; + public const REFRIGERANT_R_401_B = 'R-401B'; + public const REFRIGERANT_R_401_C = 'R-401C'; + public const REFRIGERANT_R_402_A = 'R-402A'; + public const REFRIGERANT_R_402_B = 'R-402B'; + public const REFRIGERANT_R_403_A = 'R-403A'; + public const REFRIGERANT_R_403_B = 'R-403B'; + public const REFRIGERANT_R_404_A = 'R-404A'; + public const REFRIGERANT_R_405_A = 'R-405A'; + public const REFRIGERANT_R_406_A = 'R-406A'; + public const REFRIGERANT_R_407_A = 'R-407A'; + public const REFRIGERANT_R_407_B = 'R-407B'; + public const REFRIGERANT_R_407_C = 'R-407C'; + public const REFRIGERANT_R_407_D = 'R-407D'; + public const REFRIGERANT_R_407_E = 'R-407E'; + public const REFRIGERANT_R_408_A = 'R-408A'; + public const REFRIGERANT_R_409_A = 'R-409A'; + public const REFRIGERANT_R_409_B = 'R-409B'; + public const REFRIGERANT_R_410_A = 'R-410A'; + public const REFRIGERANT_R_411_A = 'R-411A'; + public const REFRIGERANT_R_411_B = 'R-411B'; + public const REFRIGERANT_R_412_A = 'R-412A'; + public const REFRIGERANT_R_413_A = 'R-413A'; + public const REFRIGERANT_R_414_A = 'R-414A'; + public const REFRIGERANT_R_414_B = 'R-414B'; + public const REFRIGERANT_R_415_A = 'R-415A'; + public const REFRIGERANT_R_415_B = 'R-415B'; + public const REFRIGERANT_R_416_A = 'R-416A'; + public const REFRIGERANT_R_417_A = 'R-417A'; + public const REFRIGERANT_R_418_A = 'R-418A'; + public const REFRIGERANT_R_419_A = 'R-419A'; + public const REFRIGERANT_R_420_A = 'R-420A'; + public const REFRIGERANT_R_421_A = 'R-421A'; + public const REFRIGERANT_R_421_B = 'R-421B'; + public const REFRIGERANT_R_422_A = 'R-422A'; + public const REFRIGERANT_R_422_B = 'R-422B'; + public const REFRIGERANT_R_422_C = 'R-422C'; + public const REFRIGERANT_R_422_D = 'R-422D'; + public const REFRIGERANT_R_423_A = 'R-423A'; + public const REFRIGERANT_R_424_A = 'R-424A'; + public const REFRIGERANT_R_425_A = 'R-425A'; + public const REFRIGERANT_R_426_A = 'R-426A'; + public const REFRIGERANT_R_427_A = 'R-427A'; + public const REFRIGERANT_R_428_A = 'R-428A'; + public const REFRIGERANT_R_500 = 'R-500'; + public const REFRIGERANT_R_502 = 'R-502'; + public const REFRIGERANT_R_503 = 'R-503'; + public const REFRIGERANT_R_507_A = 'R-507A'; + public const REFRIGERANT_R_508_A = 'R-508A'; + public const REFRIGERANT_R_508_B = 'R-508B'; + public const REFRIGERANT_R_509_A = 'R-509A'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRefrigerantAllowableValues() + { + return [ + self::REFRIGERANT_HFC_23, + self::REFRIGERANT_HFC_32, + self::REFRIGERANT_HFC_41, + self::REFRIGERANT_HFC_43_10MEE, + self::REFRIGERANT_HFC_125, + self::REFRIGERANT_HFC_134, + self::REFRIGERANT_HFC_134A, + self::REFRIGERANT_HFC_143, + self::REFRIGERANT_HFC_143A, + self::REFRIGERANT_HFC_152A, + self::REFRIGERANT_HFC_227EA, + self::REFRIGERANT_HFC_236FA, + self::REFRIGERANT_HFC_245CA, + self::REFRIGERANT_HFC_245FA, + self::REFRIGERANT_HFC_365MFC, + self::REFRIGERANT_R438_A, + self::REFRIGERANT_R448_A, + self::REFRIGERANT_R_22, + self::REFRIGERANT_AMMONIA__R_717, + self::REFRIGERANT_R_11, + self::REFRIGERANT_R_12, + self::REFRIGERANT_R_13, + self::REFRIGERANT_R_23, + self::REFRIGERANT_R_32, + self::REFRIGERANT_R_113, + self::REFRIGERANT_R_114, + self::REFRIGERANT_R_115, + self::REFRIGERANT_R_116, + self::REFRIGERANT_R_123, + self::REFRIGERANT_R_124, + self::REFRIGERANT_R_125, + self::REFRIGERANT_R_134A, + self::REFRIGERANT_R_141B, + self::REFRIGERANT_R_142B, + self::REFRIGERANT_R_143A, + self::REFRIGERANT_R_152A, + self::REFRIGERANT_R_218, + self::REFRIGERANT_R_227EA, + self::REFRIGERANT_R_236FA, + self::REFRIGERANT_R_245CA, + self::REFRIGERANT_R_245FA, + self::REFRIGERANT_R_C318, + self::REFRIGERANT_R_401_A, + self::REFRIGERANT_R_401_B, + self::REFRIGERANT_R_401_C, + self::REFRIGERANT_R_402_A, + self::REFRIGERANT_R_402_B, + self::REFRIGERANT_R_403_A, + self::REFRIGERANT_R_403_B, + self::REFRIGERANT_R_404_A, + self::REFRIGERANT_R_405_A, + self::REFRIGERANT_R_406_A, + self::REFRIGERANT_R_407_A, + self::REFRIGERANT_R_407_B, + self::REFRIGERANT_R_407_C, + self::REFRIGERANT_R_407_D, + self::REFRIGERANT_R_407_E, + self::REFRIGERANT_R_408_A, + self::REFRIGERANT_R_409_A, + self::REFRIGERANT_R_409_B, + self::REFRIGERANT_R_410_A, + self::REFRIGERANT_R_411_A, + self::REFRIGERANT_R_411_B, + self::REFRIGERANT_R_412_A, + self::REFRIGERANT_R_413_A, + self::REFRIGERANT_R_414_A, + self::REFRIGERANT_R_414_B, + self::REFRIGERANT_R_415_A, + self::REFRIGERANT_R_415_B, + self::REFRIGERANT_R_416_A, + self::REFRIGERANT_R_417_A, + self::REFRIGERANT_R_418_A, + self::REFRIGERANT_R_419_A, + self::REFRIGERANT_R_420_A, + self::REFRIGERANT_R_421_A, + self::REFRIGERANT_R_421_B, + self::REFRIGERANT_R_422_A, + self::REFRIGERANT_R_422_B, + self::REFRIGERANT_R_422_C, + self::REFRIGERANT_R_422_D, + self::REFRIGERANT_R_423_A, + self::REFRIGERANT_R_424_A, + self::REFRIGERANT_R_425_A, + self::REFRIGERANT_R_426_A, + self::REFRIGERANT_R_427_A, + self::REFRIGERANT_R_428_A, + self::REFRIGERANT_R_500, + self::REFRIGERANT_R_502, + self::REFRIGERANT_R_503, + self::REFRIGERANT_R_507_A, + self::REFRIGERANT_R_508_A, + self::REFRIGERANT_R_508_B, + self::REFRIGERANT_R_509_A, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('refrigerant', $data ?? [], null); + $this->setIfExists('charge_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['refrigerant'] === null) { + $invalidProperties[] = "'refrigerant' can't be null"; + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!is_null($this->container['refrigerant']) && !in_array($this->container['refrigerant'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'refrigerant', must be one of '%s'", + $this->container['refrigerant'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['charge_size'] === null) { + $invalidProperties[] = "'charge_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 refrigerant + * + * @return string + */ + public function getRefrigerant() + { + return $this->container['refrigerant']; + } + + /** + * Sets refrigerant + * + * @param string $refrigerant Refrigerant type + * + * @return self + */ + public function setRefrigerant($refrigerant) + { + if (is_null($refrigerant)) { + throw new \InvalidArgumentException('non-nullable refrigerant cannot be null'); + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!in_array($refrigerant, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'refrigerant', must be one of '%s'", + $refrigerant, + implode("', '", $allowedValues) + ) + ); + } + $this->container['refrigerant'] = $refrigerant; + + return $this; + } + + /** + * Gets charge_size + * + * @return float + */ + public function getChargeSize() + { + return $this->container['charge_size']; + } + + /** + * Sets charge_size + * + * @param float $charge_size Amount of refrigerant contained in the appliance, in kg + * + * @return self + */ + public function setChargeSize($charge_size) + { + if (is_null($charge_size)) { + throw new \InvalidArgumentException('non-nullable charge_size cannot be null'); + } + $this->container['charge_size'] = $charge_size; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerSolidWaste.php b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerSolidWaste.php new file mode 100644 index 00000000..2de4bacf --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostAquacultureRequestEnterprisesInnerSolidWaste.php @@ -0,0 +1,451 @@ + + */ +class PostAquacultureRequestEnterprisesInnerSolidWaste implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_aquaculture_request_enterprises_inner_solidWaste'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sent_offsite_tonnes' => 'float', + 'onsite_composting_tonnes' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sent_offsite_tonnes' => null, + 'onsite_composting_tonnes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sent_offsite_tonnes' => false, + 'onsite_composting_tonnes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sent_offsite_tonnes' => 'sentOffsiteTonnes', + 'onsite_composting_tonnes' => 'onsiteCompostingTonnes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sent_offsite_tonnes' => 'setSentOffsiteTonnes', + 'onsite_composting_tonnes' => 'setOnsiteCompostingTonnes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sent_offsite_tonnes' => 'getSentOffsiteTonnes', + 'onsite_composting_tonnes' => 'getOnsiteCompostingTonnes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('sent_offsite_tonnes', $data ?? [], null); + $this->setIfExists('onsite_composting_tonnes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['sent_offsite_tonnes'] === null) { + $invalidProperties[] = "'sent_offsite_tonnes' can't be null"; + } + if ($this->container['onsite_composting_tonnes'] === null) { + $invalidProperties[] = "'onsite_composting_tonnes' 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 sent_offsite_tonnes + * + * @return float + */ + public function getSentOffsiteTonnes() + { + return $this->container['sent_offsite_tonnes']; + } + + /** + * Sets sent_offsite_tonnes + * + * @param float $sent_offsite_tonnes Amount of solid waste sent offsite to landfill, in tonnes + * + * @return self + */ + public function setSentOffsiteTonnes($sent_offsite_tonnes) + { + if (is_null($sent_offsite_tonnes)) { + throw new \InvalidArgumentException('non-nullable sent_offsite_tonnes cannot be null'); + } + $this->container['sent_offsite_tonnes'] = $sent_offsite_tonnes; + + return $this; + } + + /** + * Gets onsite_composting_tonnes + * + * @return float + */ + public function getOnsiteCompostingTonnes() + { + return $this->container['onsite_composting_tonnes']; + } + + /** + * Sets onsite_composting_tonnes + * + * @param float $onsite_composting_tonnes Amount of solid waste composted on site, in tonnes + * + * @return self + */ + public function setOnsiteCompostingTonnes($onsite_composting_tonnes) + { + if (is_null($onsite_composting_tonnes)) { + throw new \InvalidArgumentException('non-nullable onsite_composting_tonnes cannot be null'); + } + $this->container['onsite_composting_tonnes'] = $onsite_composting_tonnes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200Response.php b/examples/php-api-client/api-client/lib/Model/PostBeef200Response.php new file mode 100644 index 00000000..ce3d4528 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200Response.php @@ -0,0 +1,636 @@ + + */ +class PostBeef200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBeef200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostBeef200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInner.php new file mode 100644 index 00000000..35f8a6d7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostBeef200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostBeef200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..774c462d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostBeef200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'liveweight_beef_produced_kg' => 'float', + 'beef_excluding_sequestration' => 'float', + 'beef_including_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'liveweight_beef_produced_kg' => null, + 'beef_excluding_sequestration' => null, + 'beef_including_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'liveweight_beef_produced_kg' => false, + 'beef_excluding_sequestration' => false, + 'beef_including_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'liveweight_beef_produced_kg' => 'liveweightBeefProducedKg', + 'beef_excluding_sequestration' => 'beefExcludingSequestration', + 'beef_including_sequestration' => 'beefIncludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'liveweight_beef_produced_kg' => 'setLiveweightBeefProducedKg', + 'beef_excluding_sequestration' => 'setBeefExcludingSequestration', + 'beef_including_sequestration' => 'setBeefIncludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'liveweight_beef_produced_kg' => 'getLiveweightBeefProducedKg', + 'beef_excluding_sequestration' => 'getBeefExcludingSequestration', + 'beef_including_sequestration' => 'getBeefIncludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('liveweight_beef_produced_kg', $data ?? [], null); + $this->setIfExists('beef_excluding_sequestration', $data ?? [], null); + $this->setIfExists('beef_including_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['liveweight_beef_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_beef_produced_kg' can't be null"; + } + if ($this->container['beef_excluding_sequestration'] === null) { + $invalidProperties[] = "'beef_excluding_sequestration' can't be null"; + } + if ($this->container['beef_including_sequestration'] === null) { + $invalidProperties[] = "'beef_including_sequestration' 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 liveweight_beef_produced_kg + * + * @return float + */ + public function getLiveweightBeefProducedKg() + { + return $this->container['liveweight_beef_produced_kg']; + } + + /** + * Sets liveweight_beef_produced_kg + * + * @param float $liveweight_beef_produced_kg Amount of beef produced in kg liveweight + * + * @return self + */ + public function setLiveweightBeefProducedKg($liveweight_beef_produced_kg) + { + if (is_null($liveweight_beef_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_beef_produced_kg cannot be null'); + } + $this->container['liveweight_beef_produced_kg'] = $liveweight_beef_produced_kg; + + return $this; + } + + /** + * Gets beef_excluding_sequestration + * + * @return float + */ + public function getBeefExcludingSequestration() + { + return $this->container['beef_excluding_sequestration']; + } + + /** + * Sets beef_excluding_sequestration + * + * @param float $beef_excluding_sequestration Beef excluding sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefExcludingSequestration($beef_excluding_sequestration) + { + if (is_null($beef_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_excluding_sequestration cannot be null'); + } + $this->container['beef_excluding_sequestration'] = $beef_excluding_sequestration; + + return $this; + } + + /** + * Gets beef_including_sequestration + * + * @return float + */ + public function getBeefIncludingSequestration() + { + return $this->container['beef_including_sequestration']; + } + + /** + * Sets beef_including_sequestration + * + * @param float $beef_including_sequestration Beef including sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefIncludingSequestration($beef_including_sequestration) + { + if (is_null($beef_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_including_sequestration cannot be null'); + } + $this->container['beef_including_sequestration'] = $beef_including_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseNet.php new file mode 100644 index 00000000..caf73e99 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseNet.php @@ -0,0 +1,450 @@ + + */ +class PostBeef200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'beef' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'beef' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'beef' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'beef' => 'beef' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'beef' => 'setBeef' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'beef' => 'getBeef' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('beef', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['beef'] === null) { + $invalidProperties[] = "'beef' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total net emissions of this activity, in tonnes-CO2e/year + * + * @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 beef + * + * @return float + */ + public function getBeef() + { + return $this->container['beef']; + } + + /** + * Sets beef + * + * @param float $beef Net emissions of beef, in tonnes-CO2e/year + * + * @return self + */ + public function setBeef($beef) + { + if (is_null($beef)) { + throw new \InvalidArgumentException('non-nullable beef cannot be null'); + } + $this->container['beef'] = $beef; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope1.php new file mode 100644 index 00000000..79f496cd --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope1.php @@ -0,0 +1,1006 @@ + + */ +class PostBeef200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'fertiliser_n2_o' => 'float', + 'enteric_ch4' => 'float', + 'manure_management_ch4' => 'float', + 'urine_and_dung_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'savannah_burning_n2_o' => 'float', + 'savannah_burning_ch4' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'fertiliser_n2_o' => null, + 'enteric_ch4' => null, + 'manure_management_ch4' => null, + 'urine_and_dung_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'savannah_burning_n2_o' => null, + 'savannah_burning_ch4' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'fertiliser_n2_o' => false, + 'enteric_ch4' => false, + 'manure_management_ch4' => false, + 'urine_and_dung_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'savannah_burning_n2_o' => false, + 'savannah_burning_ch4' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'enteric_ch4' => 'entericCH4', + 'manure_management_ch4' => 'manureManagementCH4', + 'urine_and_dung_n2_o' => 'urineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'savannah_burning_n2_o' => 'savannahBurningN2O', + 'savannah_burning_ch4' => 'savannahBurningCH4', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'enteric_ch4' => 'setEntericCh4', + 'manure_management_ch4' => 'setManureManagementCh4', + 'urine_and_dung_n2_o' => 'setUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'savannah_burning_n2_o' => 'setSavannahBurningN2O', + 'savannah_burning_ch4' => 'setSavannahBurningCh4', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'enteric_ch4' => 'getEntericCh4', + 'manure_management_ch4' => 'getManureManagementCh4', + 'urine_and_dung_n2_o' => 'getUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'savannah_burning_n2_o' => 'getSavannahBurningN2O', + 'savannah_burning_ch4' => 'getSavannahBurningCh4', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('enteric_ch4', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('urine_and_dung_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('savannah_burning_n2_o', $data ?? [], null); + $this->setIfExists('savannah_burning_ch4', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['enteric_ch4'] === null) { + $invalidProperties[] = "'enteric_ch4' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['urine_and_dung_n2_o'] === null) { + $invalidProperties[] = "'urine_and_dung_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['savannah_burning_n2_o'] === null) { + $invalidProperties[] = "'savannah_burning_n2_o' can't be null"; + } + if ($this->container['savannah_burning_ch4'] === null) { + $invalidProperties[] = "'savannah_burning_ch4' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets enteric_ch4 + * + * @return float + */ + public function getEntericCh4() + { + return $this->container['enteric_ch4']; + } + + /** + * Sets enteric_ch4 + * + * @param float $enteric_ch4 CH4 emissions from enteric fermentation, in tonnes-CO2e + * + * @return self + */ + public function setEntericCh4($enteric_ch4) + { + if (is_null($enteric_ch4)) { + throw new \InvalidArgumentException('non-nullable enteric_ch4 cannot be null'); + } + $this->container['enteric_ch4'] = $enteric_ch4; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets urine_and_dung_n2_o + * + * @return float + */ + public function getUrineAndDungN2O() + { + return $this->container['urine_and_dung_n2_o']; + } + + /** + * Sets urine_and_dung_n2_o + * + * @param float $urine_and_dung_n2_o N2O emissions from urine and dung, in tonnes-CO2e + * + * @return self + */ + public function setUrineAndDungN2O($urine_and_dung_n2_o) + { + if (is_null($urine_and_dung_n2_o)) { + throw new \InvalidArgumentException('non-nullable urine_and_dung_n2_o cannot be null'); + } + $this->container['urine_and_dung_n2_o'] = $urine_and_dung_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets savannah_burning_n2_o + * + * @return float + */ + public function getSavannahBurningN2O() + { + return $this->container['savannah_burning_n2_o']; + } + + /** + * Sets savannah_burning_n2_o + * + * @param float $savannah_burning_n2_o N2O emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setSavannahBurningN2O($savannah_burning_n2_o) + { + if (is_null($savannah_burning_n2_o)) { + throw new \InvalidArgumentException('non-nullable savannah_burning_n2_o cannot be null'); + } + $this->container['savannah_burning_n2_o'] = $savannah_burning_n2_o; + + return $this; + } + + /** + * Gets savannah_burning_ch4 + * + * @return float + */ + public function getSavannahBurningCh4() + { + return $this->container['savannah_burning_ch4']; + } + + /** + * Sets savannah_burning_ch4 + * + * @param float $savannah_burning_ch4 CH4 emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setSavannahBurningCh4($savannah_burning_ch4) + { + if (is_null($savannah_burning_ch4)) { + throw new \InvalidArgumentException('non-nullable savannah_burning_ch4 cannot be null'); + } + $this->container['savannah_burning_ch4'] = $savannah_burning_ch4; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope3.php new file mode 100644 index 00000000..23f3e88f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeef200ResponseScope3.php @@ -0,0 +1,710 @@ + + */ +class PostBeef200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'purchased_mineral_supplementation' => 'float', + 'purchased_feed' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'purchased_livestock' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'purchased_mineral_supplementation' => null, + 'purchased_feed' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'purchased_livestock' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'purchased_mineral_supplementation' => false, + 'purchased_feed' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => false, + 'purchased_livestock' => 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 = [ + 'fertiliser' => 'fertiliser', + 'purchased_mineral_supplementation' => 'purchasedMineralSupplementation', + 'purchased_feed' => 'purchasedFeed', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'purchased_livestock' => 'purchasedLivestock', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'purchased_mineral_supplementation' => 'setPurchasedMineralSupplementation', + 'purchased_feed' => 'setPurchasedFeed', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'purchased_livestock' => 'setPurchasedLivestock', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'purchased_mineral_supplementation' => 'getPurchasedMineralSupplementation', + 'purchased_feed' => 'getPurchasedFeed', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + 'purchased_livestock' => 'getPurchasedLivestock', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('purchased_mineral_supplementation', $data ?? [], null); + $this->setIfExists('purchased_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $data ?? [], null); + $this->setIfExists('purchased_livestock', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['purchased_mineral_supplementation'] === null) { + $invalidProperties[] = "'purchased_mineral_supplementation' can't be null"; + } + if ($this->container['purchased_feed'] === null) { + $invalidProperties[] = "'purchased_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['purchased_livestock'] === null) { + $invalidProperties[] = "'purchased_livestock' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets purchased_mineral_supplementation + * + * @return float + */ + public function getPurchasedMineralSupplementation() + { + return $this->container['purchased_mineral_supplementation']; + } + + /** + * Sets purchased_mineral_supplementation + * + * @param float $purchased_mineral_supplementation Emissions from purchased mineral supplementation, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedMineralSupplementation($purchased_mineral_supplementation) + { + if (is_null($purchased_mineral_supplementation)) { + throw new \InvalidArgumentException('non-nullable purchased_mineral_supplementation cannot be null'); + } + $this->container['purchased_mineral_supplementation'] = $purchased_mineral_supplementation; + + return $this; + } + + /** + * Gets purchased_feed + * + * @return float + */ + public function getPurchasedFeed() + { + return $this->container['purchased_feed']; + } + + /** + * Sets purchased_feed + * + * @param float $purchased_feed Emissions from purchased feed, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedFeed($purchased_feed) + { + if (is_null($purchased_feed)) { + throw new \InvalidArgumentException('non-nullable purchased_feed cannot be null'); + } + $this->container['purchased_feed'] = $purchased_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets purchased_livestock + * + * @return float + */ + public function getPurchasedLivestock() + { + return $this->container['purchased_livestock']; + } + + /** + * Sets purchased_livestock + * + * @param float $purchased_livestock Emissions from purchased livestock, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedLivestock($purchased_livestock) + { + if (is_null($purchased_livestock)) { + throw new \InvalidArgumentException('non-nullable purchased_livestock cannot be null'); + } + $this->container['purchased_livestock'] = $purchased_livestock; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequest.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequest.php new file mode 100644 index 00000000..aeb75c5e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequest.php @@ -0,0 +1,647 @@ + + */ +class PostBeefRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'north_of_tropic_of_capricorn' => 'bool', + 'rainfall_above600' => 'bool', + 'beef' => '\OpenAPI\Client\Model\PostBeefRequestBeefInner[]', + 'burning' => '\OpenAPI\Client\Model\PostBeefRequestBurningInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'north_of_tropic_of_capricorn' => null, + 'rainfall_above600' => null, + 'beef' => null, + 'burning' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'north_of_tropic_of_capricorn' => false, + 'rainfall_above600' => false, + 'beef' => false, + 'burning' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'north_of_tropic_of_capricorn' => 'northOfTropicOfCapricorn', + 'rainfall_above600' => 'rainfallAbove600', + 'beef' => 'beef', + 'burning' => 'burning', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'north_of_tropic_of_capricorn' => 'setNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'setRainfallAbove600', + 'beef' => 'setBeef', + 'burning' => 'setBurning', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'north_of_tropic_of_capricorn' => 'getNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'getRainfallAbove600', + 'beef' => 'getBeef', + 'burning' => 'getBurning', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('north_of_tropic_of_capricorn', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('beef', $data ?? [], null); + $this->setIfExists('burning', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['north_of_tropic_of_capricorn'] === null) { + $invalidProperties[] = "'north_of_tropic_of_capricorn' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['beef'] === null) { + $invalidProperties[] = "'beef' can't be null"; + } + if ($this->container['burning'] === null) { + $invalidProperties[] = "'burning' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets north_of_tropic_of_capricorn + * + * @return bool + */ + public function getNorthOfTropicOfCapricorn() + { + return $this->container['north_of_tropic_of_capricorn']; + } + + /** + * Sets north_of_tropic_of_capricorn + * + * @param bool $north_of_tropic_of_capricorn Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude + * + * @return self + */ + public function setNorthOfTropicOfCapricorn($north_of_tropic_of_capricorn) + { + if (is_null($north_of_tropic_of_capricorn)) { + throw new \InvalidArgumentException('non-nullable north_of_tropic_of_capricorn cannot be null'); + } + $this->container['north_of_tropic_of_capricorn'] = $north_of_tropic_of_capricorn; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets beef + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInner[] + */ + public function getBeef() + { + return $this->container['beef']; + } + + /** + * Sets beef + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInner[] $beef beef + * + * @return self + */ + public function setBeef($beef) + { + if (is_null($beef)) { + throw new \InvalidArgumentException('non-nullable beef cannot be null'); + } + $this->container['beef'] = $beef; + + return $this; + } + + /** + * Gets burning + * + * @return \OpenAPI\Client\Model\PostBeefRequestBurningInner[] + */ + public function getBurning() + { + return $this->container['burning']; + } + + /** + * Sets burning + * + * @param \OpenAPI\Client\Model\PostBeefRequestBurningInner[] $burning burning + * + * @return self + */ + public function setBurning($burning) + { + if (is_null($burning)) { + throw new \InvalidArgumentException('non-nullable burning cannot be null'); + } + $this->container['burning'] = $burning; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInner.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInner.php new file mode 100644 index 00000000..8f4fe33f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInner.php @@ -0,0 +1,1089 @@ + + */ +class PostBeefRequestBeefInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'mineral_supplementation' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'cottonseed_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'cows_calving' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerCowsCalving' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'mineral_supplementation' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'cottonseed_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'cows_calving' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'mineral_supplementation' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'cottonseed_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'cows_calving' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'mineral_supplementation' => 'mineralSupplementation', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'cottonseed_feed' => 'cottonseedFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'cows_calving' => 'cowsCalving' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'mineral_supplementation' => 'setMineralSupplementation', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'cottonseed_feed' => 'setCottonseedFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'cows_calving' => 'setCowsCalving' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'mineral_supplementation' => 'getMineralSupplementation', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'cottonseed_feed' => 'getCottonseedFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'cows_calving' => 'getCowsCalving' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('mineral_supplementation', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('cottonseed_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('cows_calving', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['mineral_supplementation'] === null) { + $invalidProperties[] = "'mineral_supplementation' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['cottonseed_feed'] === null) { + $invalidProperties[] = "'cottonseed_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['cows_calving'] === null) { + $invalidProperties[] = "'cows_calving' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets mineral_supplementation + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation + */ + public function getMineralSupplementation() + { + return $this->container['mineral_supplementation']; + } + + /** + * Sets mineral_supplementation + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation $mineral_supplementation mineral_supplementation + * + * @return self + */ + public function setMineralSupplementation($mineral_supplementation) + { + if (is_null($mineral_supplementation)) { + throw new \InvalidArgumentException('non-nullable mineral_supplementation cannot be null'); + } + $this->container['mineral_supplementation'] = $mineral_supplementation; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostBeefRequestBeefInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostBeefRequestBeefInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets cottonseed_feed + * + * @return float + */ + public function getCottonseedFeed() + { + return $this->container['cottonseed_feed']; + } + + /** + * Sets cottonseed_feed + * + * @param float $cottonseed_feed Cotton seed purchased for cattle feed in tonnes + * + * @return self + */ + public function setCottonseedFeed($cottonseed_feed) + { + if (is_null($cottonseed_feed)) { + throw new \InvalidArgumentException('non-nullable cottonseed_feed cannot be null'); + } + $this->container['cottonseed_feed'] = $cottonseed_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets cows_calving + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerCowsCalving + */ + public function getCowsCalving() + { + return $this->container['cows_calving']; + } + + /** + * Sets cows_calving + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerCowsCalving $cows_calving cows_calving + * + * @return self + */ + public function setCowsCalving($cows_calving) + { + if (is_null($cows_calving)) { + throw new \InvalidArgumentException('non-nullable cows_calving cannot be null'); + } + $this->container['cows_calving'] = $cows_calving; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClasses.php new file mode 100644 index 00000000..e5cd266f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClasses.php @@ -0,0 +1,921 @@ + + */ +class PostBeefRequestBeefInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bulls_gt1' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1', + 'bulls_gt1_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Traded', + 'steers_lt1' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1', + 'steers_lt1_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1Traded', + 'steers1_to2' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2', + 'steers1_to2_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2Traded', + 'steers_gt2' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2', + 'steers_gt2_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2Traded', + 'cows_gt2' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2', + 'cows_gt2_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2Traded', + 'heifers_lt1' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1', + 'heifers_lt1_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1Traded', + 'heifers1_to2' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2', + 'heifers1_to2_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2Traded', + 'heifers_gt2' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2', + 'heifers_gt2_traded' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2Traded' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bulls_gt1' => null, + 'bulls_gt1_traded' => null, + 'steers_lt1' => null, + 'steers_lt1_traded' => null, + 'steers1_to2' => null, + 'steers1_to2_traded' => null, + 'steers_gt2' => null, + 'steers_gt2_traded' => null, + 'cows_gt2' => null, + 'cows_gt2_traded' => null, + 'heifers_lt1' => null, + 'heifers_lt1_traded' => null, + 'heifers1_to2' => null, + 'heifers1_to2_traded' => null, + 'heifers_gt2' => null, + 'heifers_gt2_traded' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bulls_gt1' => false, + 'bulls_gt1_traded' => false, + 'steers_lt1' => false, + 'steers_lt1_traded' => false, + 'steers1_to2' => false, + 'steers1_to2_traded' => false, + 'steers_gt2' => false, + 'steers_gt2_traded' => false, + 'cows_gt2' => false, + 'cows_gt2_traded' => false, + 'heifers_lt1' => false, + 'heifers_lt1_traded' => false, + 'heifers1_to2' => false, + 'heifers1_to2_traded' => false, + 'heifers_gt2' => false, + 'heifers_gt2_traded' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bulls_gt1' => 'bullsGt1', + 'bulls_gt1_traded' => 'bullsGt1Traded', + 'steers_lt1' => 'steersLt1', + 'steers_lt1_traded' => 'steersLt1Traded', + 'steers1_to2' => 'steers1To2', + 'steers1_to2_traded' => 'steers1To2Traded', + 'steers_gt2' => 'steersGt2', + 'steers_gt2_traded' => 'steersGt2Traded', + 'cows_gt2' => 'cowsGt2', + 'cows_gt2_traded' => 'cowsGt2Traded', + 'heifers_lt1' => 'heifersLt1', + 'heifers_lt1_traded' => 'heifersLt1Traded', + 'heifers1_to2' => 'heifers1To2', + 'heifers1_to2_traded' => 'heifers1To2Traded', + 'heifers_gt2' => 'heifersGt2', + 'heifers_gt2_traded' => 'heifersGt2Traded' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bulls_gt1' => 'setBullsGt1', + 'bulls_gt1_traded' => 'setBullsGt1Traded', + 'steers_lt1' => 'setSteersLt1', + 'steers_lt1_traded' => 'setSteersLt1Traded', + 'steers1_to2' => 'setSteers1To2', + 'steers1_to2_traded' => 'setSteers1To2Traded', + 'steers_gt2' => 'setSteersGt2', + 'steers_gt2_traded' => 'setSteersGt2Traded', + 'cows_gt2' => 'setCowsGt2', + 'cows_gt2_traded' => 'setCowsGt2Traded', + 'heifers_lt1' => 'setHeifersLt1', + 'heifers_lt1_traded' => 'setHeifersLt1Traded', + 'heifers1_to2' => 'setHeifers1To2', + 'heifers1_to2_traded' => 'setHeifers1To2Traded', + 'heifers_gt2' => 'setHeifersGt2', + 'heifers_gt2_traded' => 'setHeifersGt2Traded' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bulls_gt1' => 'getBullsGt1', + 'bulls_gt1_traded' => 'getBullsGt1Traded', + 'steers_lt1' => 'getSteersLt1', + 'steers_lt1_traded' => 'getSteersLt1Traded', + 'steers1_to2' => 'getSteers1To2', + 'steers1_to2_traded' => 'getSteers1To2Traded', + 'steers_gt2' => 'getSteersGt2', + 'steers_gt2_traded' => 'getSteersGt2Traded', + 'cows_gt2' => 'getCowsGt2', + 'cows_gt2_traded' => 'getCowsGt2Traded', + 'heifers_lt1' => 'getHeifersLt1', + 'heifers_lt1_traded' => 'getHeifersLt1Traded', + 'heifers1_to2' => 'getHeifers1To2', + 'heifers1_to2_traded' => 'getHeifers1To2Traded', + 'heifers_gt2' => 'getHeifersGt2', + 'heifers_gt2_traded' => 'getHeifersGt2Traded' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bulls_gt1', $data ?? [], null); + $this->setIfExists('bulls_gt1_traded', $data ?? [], null); + $this->setIfExists('steers_lt1', $data ?? [], null); + $this->setIfExists('steers_lt1_traded', $data ?? [], null); + $this->setIfExists('steers1_to2', $data ?? [], null); + $this->setIfExists('steers1_to2_traded', $data ?? [], null); + $this->setIfExists('steers_gt2', $data ?? [], null); + $this->setIfExists('steers_gt2_traded', $data ?? [], null); + $this->setIfExists('cows_gt2', $data ?? [], null); + $this->setIfExists('cows_gt2_traded', $data ?? [], null); + $this->setIfExists('heifers_lt1', $data ?? [], null); + $this->setIfExists('heifers_lt1_traded', $data ?? [], null); + $this->setIfExists('heifers1_to2', $data ?? [], null); + $this->setIfExists('heifers1_to2_traded', $data ?? [], null); + $this->setIfExists('heifers_gt2', $data ?? [], null); + $this->setIfExists('heifers_gt2_traded', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 bulls_gt1 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1|null + */ + public function getBullsGt1() + { + return $this->container['bulls_gt1']; + } + + /** + * Sets bulls_gt1 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1|null $bulls_gt1 bulls_gt1 + * + * @return self + */ + public function setBullsGt1($bulls_gt1) + { + if (is_null($bulls_gt1)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1 cannot be null'); + } + $this->container['bulls_gt1'] = $bulls_gt1; + + return $this; + } + + /** + * Gets bulls_gt1_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Traded|null + */ + public function getBullsGt1Traded() + { + return $this->container['bulls_gt1_traded']; + } + + /** + * Sets bulls_gt1_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Traded|null $bulls_gt1_traded bulls_gt1_traded + * + * @return self + */ + public function setBullsGt1Traded($bulls_gt1_traded) + { + if (is_null($bulls_gt1_traded)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1_traded cannot be null'); + } + $this->container['bulls_gt1_traded'] = $bulls_gt1_traded; + + return $this; + } + + /** + * Gets steers_lt1 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1|null + */ + public function getSteersLt1() + { + return $this->container['steers_lt1']; + } + + /** + * Sets steers_lt1 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1|null $steers_lt1 steers_lt1 + * + * @return self + */ + public function setSteersLt1($steers_lt1) + { + if (is_null($steers_lt1)) { + throw new \InvalidArgumentException('non-nullable steers_lt1 cannot be null'); + } + $this->container['steers_lt1'] = $steers_lt1; + + return $this; + } + + /** + * Gets steers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1Traded|null + */ + public function getSteersLt1Traded() + { + return $this->container['steers_lt1_traded']; + } + + /** + * Sets steers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersLt1Traded|null $steers_lt1_traded steers_lt1_traded + * + * @return self + */ + public function setSteersLt1Traded($steers_lt1_traded) + { + if (is_null($steers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable steers_lt1_traded cannot be null'); + } + $this->container['steers_lt1_traded'] = $steers_lt1_traded; + + return $this; + } + + /** + * Gets steers1_to2 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2|null + */ + public function getSteers1To2() + { + return $this->container['steers1_to2']; + } + + /** + * Sets steers1_to2 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2|null $steers1_to2 steers1_to2 + * + * @return self + */ + public function setSteers1To2($steers1_to2) + { + if (is_null($steers1_to2)) { + throw new \InvalidArgumentException('non-nullable steers1_to2 cannot be null'); + } + $this->container['steers1_to2'] = $steers1_to2; + + return $this; + } + + /** + * Gets steers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2Traded|null + */ + public function getSteers1To2Traded() + { + return $this->container['steers1_to2_traded']; + } + + /** + * Sets steers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteers1To2Traded|null $steers1_to2_traded steers1_to2_traded + * + * @return self + */ + public function setSteers1To2Traded($steers1_to2_traded) + { + if (is_null($steers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable steers1_to2_traded cannot be null'); + } + $this->container['steers1_to2_traded'] = $steers1_to2_traded; + + return $this; + } + + /** + * Gets steers_gt2 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2|null + */ + public function getSteersGt2() + { + return $this->container['steers_gt2']; + } + + /** + * Sets steers_gt2 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2|null $steers_gt2 steers_gt2 + * + * @return self + */ + public function setSteersGt2($steers_gt2) + { + if (is_null($steers_gt2)) { + throw new \InvalidArgumentException('non-nullable steers_gt2 cannot be null'); + } + $this->container['steers_gt2'] = $steers_gt2; + + return $this; + } + + /** + * Gets steers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2Traded|null + */ + public function getSteersGt2Traded() + { + return $this->container['steers_gt2_traded']; + } + + /** + * Sets steers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesSteersGt2Traded|null $steers_gt2_traded steers_gt2_traded + * + * @return self + */ + public function setSteersGt2Traded($steers_gt2_traded) + { + if (is_null($steers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable steers_gt2_traded cannot be null'); + } + $this->container['steers_gt2_traded'] = $steers_gt2_traded; + + return $this; + } + + /** + * Gets cows_gt2 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2|null + */ + public function getCowsGt2() + { + return $this->container['cows_gt2']; + } + + /** + * Sets cows_gt2 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2|null $cows_gt2 cows_gt2 + * + * @return self + */ + public function setCowsGt2($cows_gt2) + { + if (is_null($cows_gt2)) { + throw new \InvalidArgumentException('non-nullable cows_gt2 cannot be null'); + } + $this->container['cows_gt2'] = $cows_gt2; + + return $this; + } + + /** + * Gets cows_gt2_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2Traded|null + */ + public function getCowsGt2Traded() + { + return $this->container['cows_gt2_traded']; + } + + /** + * Sets cows_gt2_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesCowsGt2Traded|null $cows_gt2_traded cows_gt2_traded + * + * @return self + */ + public function setCowsGt2Traded($cows_gt2_traded) + { + if (is_null($cows_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable cows_gt2_traded cannot be null'); + } + $this->container['cows_gt2_traded'] = $cows_gt2_traded; + + return $this; + } + + /** + * Gets heifers_lt1 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1|null + */ + public function getHeifersLt1() + { + return $this->container['heifers_lt1']; + } + + /** + * Sets heifers_lt1 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1|null $heifers_lt1 heifers_lt1 + * + * @return self + */ + public function setHeifersLt1($heifers_lt1) + { + if (is_null($heifers_lt1)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1 cannot be null'); + } + $this->container['heifers_lt1'] = $heifers_lt1; + + return $this; + } + + /** + * Gets heifers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1Traded|null + */ + public function getHeifersLt1Traded() + { + return $this->container['heifers_lt1_traded']; + } + + /** + * Sets heifers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersLt1Traded|null $heifers_lt1_traded heifers_lt1_traded + * + * @return self + */ + public function setHeifersLt1Traded($heifers_lt1_traded) + { + if (is_null($heifers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1_traded cannot be null'); + } + $this->container['heifers_lt1_traded'] = $heifers_lt1_traded; + + return $this; + } + + /** + * Gets heifers1_to2 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2|null + */ + public function getHeifers1To2() + { + return $this->container['heifers1_to2']; + } + + /** + * Sets heifers1_to2 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2|null $heifers1_to2 heifers1_to2 + * + * @return self + */ + public function setHeifers1To2($heifers1_to2) + { + if (is_null($heifers1_to2)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2 cannot be null'); + } + $this->container['heifers1_to2'] = $heifers1_to2; + + return $this; + } + + /** + * Gets heifers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2Traded|null + */ + public function getHeifers1To2Traded() + { + return $this->container['heifers1_to2_traded']; + } + + /** + * Sets heifers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifers1To2Traded|null $heifers1_to2_traded heifers1_to2_traded + * + * @return self + */ + public function setHeifers1To2Traded($heifers1_to2_traded) + { + if (is_null($heifers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2_traded cannot be null'); + } + $this->container['heifers1_to2_traded'] = $heifers1_to2_traded; + + return $this; + } + + /** + * Gets heifers_gt2 + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2|null + */ + public function getHeifersGt2() + { + return $this->container['heifers_gt2']; + } + + /** + * Sets heifers_gt2 + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2|null $heifers_gt2 heifers_gt2 + * + * @return self + */ + public function setHeifersGt2($heifers_gt2) + { + if (is_null($heifers_gt2)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2 cannot be null'); + } + $this->container['heifers_gt2'] = $heifers_gt2; + + return $this; + } + + /** + * Gets heifers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2Traded|null + */ + public function getHeifersGt2Traded() + { + return $this->container['heifers_gt2_traded']; + } + + /** + * Sets heifers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesHeifersGt2Traded|null $heifers_gt2_traded heifers_gt2_traded + * + * @return self + */ + public function setHeifersGt2Traded($heifers_gt2_traded) + { + if (is_null($heifers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2_traded cannot be null'); + } + $this->container['heifers_gt2_traded'] = $heifers_gt2_traded; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1.php new file mode 100644 index 00000000..5d56f66f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesBullsGt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_bullsGt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Autumn.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Autumn.php new file mode 100644 index 00000000..7237e205 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Autumn.php @@ -0,0 +1,555 @@ + + */ +class PostBeefRequestBeefInnerClassesBullsGt1Autumn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_bullsGt1_autumn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'liveweight' => 'float', + 'liveweight_gain' => 'float', + 'crude_protein' => 'float', + 'dry_matter_digestibility' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'liveweight' => null, + 'liveweight_gain' => null, + 'crude_protein' => null, + 'dry_matter_digestibility' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'liveweight' => false, + 'liveweight_gain' => false, + 'crude_protein' => false, + 'dry_matter_digestibility' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head', + 'liveweight' => 'liveweight', + 'liveweight_gain' => 'liveweightGain', + 'crude_protein' => 'crudeProtein', + 'dry_matter_digestibility' => 'dryMatterDigestibility' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'liveweight' => 'setLiveweight', + 'liveweight_gain' => 'setLiveweightGain', + 'crude_protein' => 'setCrudeProtein', + 'dry_matter_digestibility' => 'setDryMatterDigestibility' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'liveweight' => 'getLiveweight', + 'liveweight_gain' => 'getLiveweightGain', + 'crude_protein' => 'getCrudeProtein', + 'dry_matter_digestibility' => 'getDryMatterDigestibility' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('liveweight', $data ?? [], null); + $this->setIfExists('liveweight_gain', $data ?? [], null); + $this->setIfExists('crude_protein', $data ?? [], null); + $this->setIfExists('dry_matter_digestibility', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['liveweight'] === null) { + $invalidProperties[] = "'liveweight' can't be null"; + } + if ($this->container['liveweight_gain'] === null) { + $invalidProperties[] = "'liveweight_gain' 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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets liveweight + * + * @return float + */ + public function getLiveweight() + { + return $this->container['liveweight']; + } + + /** + * Sets liveweight + * + * @param float $liveweight Average liveweight of animals in kg/head (kilogram per head) + * + * @return self + */ + public function setLiveweight($liveweight) + { + if (is_null($liveweight)) { + throw new \InvalidArgumentException('non-nullable liveweight cannot be null'); + } + $this->container['liveweight'] = $liveweight; + + return $this; + } + + /** + * Gets liveweight_gain + * + * @return float + */ + public function getLiveweightGain() + { + return $this->container['liveweight_gain']; + } + + /** + * Sets liveweight_gain + * + * @param float $liveweight_gain Average liveweight gain in kg/day (kilogram per day) + * + * @return self + */ + public function setLiveweightGain($liveweight_gain) + { + if (is_null($liveweight_gain)) { + throw new \InvalidArgumentException('non-nullable liveweight_gain cannot be null'); + } + $this->container['liveweight_gain'] = $liveweight_gain; + + return $this; + } + + /** + * Gets crude_protein + * + * @return float|null + */ + public function getCrudeProtein() + { + return $this->container['crude_protein']; + } + + /** + * Sets crude_protein + * + * @param float|null $crude_protein Crude protein percent, between 0 and 100 + * + * @return self + */ + public function setCrudeProtein($crude_protein) + { + if (is_null($crude_protein)) { + throw new \InvalidArgumentException('non-nullable crude_protein cannot be null'); + } + $this->container['crude_protein'] = $crude_protein; + + return $this; + } + + /** + * Gets dry_matter_digestibility + * + * @return float|null + */ + public function getDryMatterDigestibility() + { + return $this->container['dry_matter_digestibility']; + } + + /** + * Sets dry_matter_digestibility + * + * @param float|null $dry_matter_digestibility Dry matter digestibility percent, between 0 and 100 + * + * @return self + */ + public function setDryMatterDigestibility($dry_matter_digestibility) + { + if (is_null($dry_matter_digestibility)) { + throw new \InvalidArgumentException('non-nullable dry_matter_digestibility cannot be null'); + } + $this->container['dry_matter_digestibility'] = $dry_matter_digestibility; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.php new file mode 100644 index 00000000..a21e0c90 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.php @@ -0,0 +1,534 @@ + + */ +class PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_bullsGt1_purchases_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float', + 'purchase_source' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null, + 'purchase_source' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_weight' => false, + 'purchase_source' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight', + 'purchase_source' => 'purchaseSource' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight', + 'purchase_source' => 'setPurchaseSource' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight', + 'purchase_source' => 'getPurchaseSource' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const PURCHASE_SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const PURCHASE_SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const PURCHASE_SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const PURCHASE_SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const PURCHASE_SOURCE_SW_WA = 'sw WA'; + public const PURCHASE_SOURCE_WA_PASTORAL = 'WA pastoral'; + public const PURCHASE_SOURCE_TAS = 'TAS'; + public const PURCHASE_SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPurchaseSourceAllowableValues() + { + return [ + self::PURCHASE_SOURCE_DAIRY_ORIGIN, + self::PURCHASE_SOURCE_NTH_STH_CENTRAL_QLD, + self::PURCHASE_SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::PURCHASE_SOURCE_NSW_SA_PASTORAL_ZONE, + self::PURCHASE_SOURCE_SW_WA, + self::PURCHASE_SOURCE_WA_PASTORAL, + self::PURCHASE_SOURCE_TAS, + self::PURCHASE_SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_weight', $data ?? [], null); + $this->setIfExists('purchase_source', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_weight' can't be null"; + } + if ($this->container['purchase_source'] === null) { + $invalidProperties[] = "'purchase_source' can't be null"; + } + $allowedValues = $this->getPurchaseSourceAllowableValues(); + if (!is_null($this->container['purchase_source']) && !in_array($this->container['purchase_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'purchase_source', must be one of '%s'", + $this->container['purchase_source'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + + /** + * Gets purchase_source + * + * @return string + */ + public function getPurchaseSource() + { + return $this->container['purchase_source']; + } + + /** + * Sets purchase_source + * + * @param string $purchase_source Source location of livestock purchase + * + * @return self + */ + public function setPurchaseSource($purchase_source) + { + if (is_null($purchase_source)) { + throw new \InvalidArgumentException('non-nullable purchase_source cannot be null'); + } + $allowedValues = $this->getPurchaseSourceAllowableValues(); + if (!in_array($purchase_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'purchase_source', must be one of '%s'", + $purchase_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['purchase_source'] = $purchase_source; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Traded.php new file mode 100644 index 00000000..6b654300 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesBullsGt1Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesBullsGt1Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_bullsGt1Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2.php new file mode 100644 index 00000000..919ae46e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesCowsGt2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_cowsGt2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2Traded.php new file mode 100644 index 00000000..d63537ed --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesCowsGt2Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesCowsGt2Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_cowsGt2Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2.php new file mode 100644 index 00000000..742c84b3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifers1To2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifers1To2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2Traded.php new file mode 100644 index 00000000..d1ef789b --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifers1To2Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifers1To2Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifers1To2Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2.php new file mode 100644 index 00000000..11d00ec5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifersGt2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifersGt2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2Traded.php new file mode 100644 index 00000000..b6830d1d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersGt2Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifersGt2Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifersGt2Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1.php new file mode 100644 index 00000000..a85ad460 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifersLt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifersLt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1Traded.php new file mode 100644 index 00000000..eefe9bde --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesHeifersLt1Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesHeifersLt1Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_heifersLt1Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2.php new file mode 100644 index 00000000..68e854d7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteers1To2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steers1To2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2Traded.php new file mode 100644 index 00000000..1cc061a3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteers1To2Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteers1To2Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steers1To2Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2.php new file mode 100644 index 00000000..fc30dc67 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteersGt2 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steersGt2'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2Traded.php new file mode 100644 index 00000000..a5834454 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersGt2Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteersGt2Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steersGt2Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1.php new file mode 100644 index 00000000..460b8a15 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteersLt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steersLt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1Traded.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1Traded.php new file mode 100644 index 00000000..9ee39933 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerClassesSteersLt1Traded.php @@ -0,0 +1,787 @@ + + */ +class PostBeefRequestBeefInnerClassesSteersLt1Traded implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_classes_steersLt1Traded'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'winter' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'spring' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'summer' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'source' => 'string', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'source' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'source' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'source' => 'source', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'source' => 'setSource', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'source' => 'getSource', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SOURCE_DAIRY_ORIGIN = 'Dairy origin'; + public const SOURCE_NTH_STH_CENTRAL_QLD = 'nth/sth/central QLD'; + public const SOURCE_NTH_STH_NSW_VIC_STH_SA = 'nth/sth NSW/VIC/sth SA'; + public const SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const SOURCE_SW_WA = 'sw WA'; + public const SOURCE_WA_PASTORAL = 'WA pastoral'; + public const SOURCE_TAS = 'TAS'; + public const SOURCE_NT = 'NT'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSourceAllowableValues() + { + return [ + self::SOURCE_DAIRY_ORIGIN, + self::SOURCE_NTH_STH_CENTRAL_QLD, + self::SOURCE_NTH_STH_NSW_VIC_STH_SA, + self::SOURCE_NSW_SA_PASTORAL_ZONE, + self::SOURCE_SW_WA, + self::SOURCE_WA_PASTORAL, + self::SOURCE_TAS, + self::SOURCE_NT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + $allowedValues = $this->getSourceAllowableValues(); + if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'source', must be one of '%s'", + $this->container['source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1Autumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets source + * + * @return string|null + * @deprecated + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param string|null $source Source location of livestock purchase. Deprecation note: Use `purchases` instead + * + * @return self + * @deprecated + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $allowedValues = $this->getSourceAllowableValues(); + if (!in_array($source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'source', must be one of '%s'", + $source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerCowsCalving.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerCowsCalving.php new file mode 100644 index 00000000..49ed560f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerCowsCalving.php @@ -0,0 +1,525 @@ + + */ +class PostBeefRequestBeefInnerCowsCalving implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_cowsCalving'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => 'float', + 'summer' => 'float', + 'autumn' => 'float', + 'winter' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliser.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliser.php new file mode 100644 index 00000000..77531304 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliser.php @@ -0,0 +1,762 @@ + + */ +class PostBeefRequestBeefInnerFertiliser implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_fertiliser'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'single_superphosphate' => 'float', + 'other_type' => 'string', + 'pasture_dryland' => 'float', + 'pasture_irrigated' => 'float', + 'crops_dryland' => 'float', + 'crops_irrigated' => 'float', + 'other_dryland' => 'float', + 'other_irrigated' => 'float', + 'other_fertilisers' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliserOtherFertilisersInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'single_superphosphate' => null, + 'other_type' => null, + 'pasture_dryland' => null, + 'pasture_irrigated' => null, + 'crops_dryland' => null, + 'crops_irrigated' => null, + 'other_dryland' => null, + 'other_irrigated' => null, + 'other_fertilisers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'single_superphosphate' => false, + 'other_type' => false, + 'pasture_dryland' => false, + 'pasture_irrigated' => false, + 'crops_dryland' => false, + 'crops_irrigated' => false, + 'other_dryland' => false, + 'other_irrigated' => false, + 'other_fertilisers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'single_superphosphate' => 'singleSuperphosphate', + 'other_type' => 'otherType', + 'pasture_dryland' => 'pastureDryland', + 'pasture_irrigated' => 'pastureIrrigated', + 'crops_dryland' => 'cropsDryland', + 'crops_irrigated' => 'cropsIrrigated', + 'other_dryland' => 'otherDryland', + 'other_irrigated' => 'otherIrrigated', + 'other_fertilisers' => 'otherFertilisers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'single_superphosphate' => 'setSingleSuperphosphate', + 'other_type' => 'setOtherType', + 'pasture_dryland' => 'setPastureDryland', + 'pasture_irrigated' => 'setPastureIrrigated', + 'crops_dryland' => 'setCropsDryland', + 'crops_irrigated' => 'setCropsIrrigated', + 'other_dryland' => 'setOtherDryland', + 'other_irrigated' => 'setOtherIrrigated', + 'other_fertilisers' => 'setOtherFertilisers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'single_superphosphate' => 'getSingleSuperphosphate', + 'other_type' => 'getOtherType', + 'pasture_dryland' => 'getPastureDryland', + 'pasture_irrigated' => 'getPastureIrrigated', + 'crops_dryland' => 'getCropsDryland', + 'crops_irrigated' => 'getCropsIrrigated', + 'other_dryland' => 'getOtherDryland', + 'other_irrigated' => 'getOtherIrrigated', + 'other_fertilisers' => 'getOtherFertilisers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const OTHER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP = 'Monoammonium phosphate (MAP)'; + public const OTHER_TYPE_DIAMMONIUM_PHOSPHATE__DAP = 'Diammonium Phosphate (DAP)'; + public const OTHER_TYPE_UREA_AMMONIUM_NITRATE__UAN = 'Urea-Ammonium Nitrate (UAN)'; + public const OTHER_TYPE_AMMONIUM_NITRATE__AN = 'Ammonium Nitrate (AN)'; + public const OTHER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN = 'Calcium Ammonium Nitrate (CAN)'; + public const OTHER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP = 'Triple Superphosphate (TSP)'; + public const OTHER_TYPE_SUPER_POTASH_1_1 = 'Super Potash 1:1'; + public const OTHER_TYPE_SUPER_POTASH_2_1 = 'Super Potash 2:1'; + public const OTHER_TYPE_SUPER_POTASH_3_1 = 'Super Potash 3:1'; + public const OTHER_TYPE_SUPER_POTASH_4_1 = 'Super Potash 4:1'; + public const OTHER_TYPE_SUPER_POTASH_5_1 = 'Super Potash 5:1'; + public const OTHER_TYPE_MURIATE_OF_POTASH = 'Muriate of Potash'; + public const OTHER_TYPE_SULPHATE_OF_POTASH = 'Sulphate of Potash'; + public const OTHER_TYPE_SULPHATE_OF_AMMONIA = 'Sulphate of Ammonia'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getOtherTypeAllowableValues() + { + return [ + self::OTHER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP, + self::OTHER_TYPE_DIAMMONIUM_PHOSPHATE__DAP, + self::OTHER_TYPE_UREA_AMMONIUM_NITRATE__UAN, + self::OTHER_TYPE_AMMONIUM_NITRATE__AN, + self::OTHER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN, + self::OTHER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP, + self::OTHER_TYPE_SUPER_POTASH_1_1, + self::OTHER_TYPE_SUPER_POTASH_2_1, + self::OTHER_TYPE_SUPER_POTASH_3_1, + self::OTHER_TYPE_SUPER_POTASH_4_1, + self::OTHER_TYPE_SUPER_POTASH_5_1, + self::OTHER_TYPE_MURIATE_OF_POTASH, + self::OTHER_TYPE_SULPHATE_OF_POTASH, + self::OTHER_TYPE_SULPHATE_OF_AMMONIA, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('single_superphosphate', $data ?? [], null); + $this->setIfExists('other_type', $data ?? [], null); + $this->setIfExists('pasture_dryland', $data ?? [], null); + $this->setIfExists('pasture_irrigated', $data ?? [], null); + $this->setIfExists('crops_dryland', $data ?? [], null); + $this->setIfExists('crops_irrigated', $data ?? [], null); + $this->setIfExists('other_dryland', $data ?? [], null); + $this->setIfExists('other_irrigated', $data ?? [], null); + $this->setIfExists('other_fertilisers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['single_superphosphate'] === null) { + $invalidProperties[] = "'single_superphosphate' can't be null"; + } + $allowedValues = $this->getOtherTypeAllowableValues(); + if (!is_null($this->container['other_type']) && !in_array($this->container['other_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'other_type', must be one of '%s'", + $this->container['other_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['pasture_dryland'] === null) { + $invalidProperties[] = "'pasture_dryland' can't be null"; + } + if ($this->container['pasture_irrigated'] === null) { + $invalidProperties[] = "'pasture_irrigated' can't be null"; + } + if ($this->container['crops_dryland'] === null) { + $invalidProperties[] = "'crops_dryland' can't be null"; + } + if ($this->container['crops_irrigated'] === null) { + $invalidProperties[] = "'crops_irrigated' 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 single_superphosphate + * + * @return float + */ + public function getSingleSuperphosphate() + { + return $this->container['single_superphosphate']; + } + + /** + * Sets single_superphosphate + * + * @param float $single_superphosphate Single superphosphate usage in tonnes + * + * @return self + */ + public function setSingleSuperphosphate($single_superphosphate) + { + if (is_null($single_superphosphate)) { + throw new \InvalidArgumentException('non-nullable single_superphosphate cannot be null'); + } + $this->container['single_superphosphate'] = $single_superphosphate; + + return $this; + } + + /** + * Gets other_type + * + * @return string|null + * @deprecated + */ + public function getOtherType() + { + return $this->container['other_type']; + } + + /** + * Sets other_type + * + * @param string|null $other_type Other N fertiliser type. Deprecation note: Use `otherFertilisers` instead + * + * @return self + * @deprecated + */ + public function setOtherType($other_type) + { + if (is_null($other_type)) { + throw new \InvalidArgumentException('non-nullable other_type cannot be null'); + } + $allowedValues = $this->getOtherTypeAllowableValues(); + if (!in_array($other_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'other_type', must be one of '%s'", + $other_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['other_type'] = $other_type; + + return $this; + } + + /** + * Gets pasture_dryland + * + * @return float + */ + public function getPastureDryland() + { + return $this->container['pasture_dryland']; + } + + /** + * Sets pasture_dryland + * + * @param float $pasture_dryland Urea fertiliser used for dryland pasture, in tonnes Urea + * + * @return self + */ + public function setPastureDryland($pasture_dryland) + { + if (is_null($pasture_dryland)) { + throw new \InvalidArgumentException('non-nullable pasture_dryland cannot be null'); + } + $this->container['pasture_dryland'] = $pasture_dryland; + + return $this; + } + + /** + * Gets pasture_irrigated + * + * @return float + */ + public function getPastureIrrigated() + { + return $this->container['pasture_irrigated']; + } + + /** + * Sets pasture_irrigated + * + * @param float $pasture_irrigated Urea fertiliser used for irrigated pasture, in tonnes Urea + * + * @return self + */ + public function setPastureIrrigated($pasture_irrigated) + { + if (is_null($pasture_irrigated)) { + throw new \InvalidArgumentException('non-nullable pasture_irrigated cannot be null'); + } + $this->container['pasture_irrigated'] = $pasture_irrigated; + + return $this; + } + + /** + * Gets crops_dryland + * + * @return float + */ + public function getCropsDryland() + { + return $this->container['crops_dryland']; + } + + /** + * Sets crops_dryland + * + * @param float $crops_dryland Urea fertiliser used for dryland crops, in tonnes Urea + * + * @return self + */ + public function setCropsDryland($crops_dryland) + { + if (is_null($crops_dryland)) { + throw new \InvalidArgumentException('non-nullable crops_dryland cannot be null'); + } + $this->container['crops_dryland'] = $crops_dryland; + + return $this; + } + + /** + * Gets crops_irrigated + * + * @return float + */ + public function getCropsIrrigated() + { + return $this->container['crops_irrigated']; + } + + /** + * Sets crops_irrigated + * + * @param float $crops_irrigated Urea fertiliser used for irrigated crops, in tonnes Urea + * + * @return self + */ + public function setCropsIrrigated($crops_irrigated) + { + if (is_null($crops_irrigated)) { + throw new \InvalidArgumentException('non-nullable crops_irrigated cannot be null'); + } + $this->container['crops_irrigated'] = $crops_irrigated; + + return $this; + } + + /** + * Gets other_dryland + * + * @return float|null + * @deprecated + */ + public function getOtherDryland() + { + return $this->container['other_dryland']; + } + + /** + * Sets other_dryland + * + * @param float|null $other_dryland Other N fertiliser used for dryland. Deprecation note: Use `otherFertilisers` instead + * + * @return self + * @deprecated + */ + public function setOtherDryland($other_dryland) + { + if (is_null($other_dryland)) { + throw new \InvalidArgumentException('non-nullable other_dryland cannot be null'); + } + $this->container['other_dryland'] = $other_dryland; + + return $this; + } + + /** + * Gets other_irrigated + * + * @return float|null + * @deprecated + */ + public function getOtherIrrigated() + { + return $this->container['other_irrigated']; + } + + /** + * Sets other_irrigated + * + * @param float|null $other_irrigated Other N fertiliser used for irrigated. Deprecation note: Use `otherFertilisers` instead + * + * @return self + * @deprecated + */ + public function setOtherIrrigated($other_irrigated) + { + if (is_null($other_irrigated)) { + throw new \InvalidArgumentException('non-nullable other_irrigated cannot be null'); + } + $this->container['other_irrigated'] = $other_irrigated; + + return $this; + } + + /** + * Gets other_fertilisers + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliserOtherFertilisersInner[]|null + */ + public function getOtherFertilisers() + { + return $this->container['other_fertilisers']; + } + + /** + * Sets other_fertilisers + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliserOtherFertilisersInner[]|null $other_fertilisers Array of Other N fertiliser. Version note: If this field is set and has a length > 0, the `other` fields within this object are ignored, and this array is used instead + * + * @return self + */ + public function setOtherFertilisers($other_fertilisers) + { + if (is_null($other_fertilisers)) { + throw new \InvalidArgumentException('non-nullable other_fertilisers cannot be null'); + } + $this->container['other_fertilisers'] = $other_fertilisers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.php new file mode 100644 index 00000000..56c91b96 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.php @@ -0,0 +1,546 @@ + + */ +class PostBeefRequestBeefInnerFertiliserOtherFertilisersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_fertiliser_otherFertilisers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'other_type' => 'string', + 'other_dryland' => 'float', + 'other_irrigated' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'other_type' => null, + 'other_dryland' => null, + 'other_irrigated' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'other_type' => false, + 'other_dryland' => false, + 'other_irrigated' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'other_type' => 'otherType', + 'other_dryland' => 'otherDryland', + 'other_irrigated' => 'otherIrrigated' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'other_type' => 'setOtherType', + 'other_dryland' => 'setOtherDryland', + 'other_irrigated' => 'setOtherIrrigated' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'other_type' => 'getOtherType', + 'other_dryland' => 'getOtherDryland', + 'other_irrigated' => 'getOtherIrrigated' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const OTHER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP = 'Monoammonium phosphate (MAP)'; + public const OTHER_TYPE_DIAMMONIUM_PHOSPHATE__DAP = 'Diammonium Phosphate (DAP)'; + public const OTHER_TYPE_UREA_AMMONIUM_NITRATE__UAN = 'Urea-Ammonium Nitrate (UAN)'; + public const OTHER_TYPE_AMMONIUM_NITRATE__AN = 'Ammonium Nitrate (AN)'; + public const OTHER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN = 'Calcium Ammonium Nitrate (CAN)'; + public const OTHER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP = 'Triple Superphosphate (TSP)'; + public const OTHER_TYPE_SUPER_POTASH_1_1 = 'Super Potash 1:1'; + public const OTHER_TYPE_SUPER_POTASH_2_1 = 'Super Potash 2:1'; + public const OTHER_TYPE_SUPER_POTASH_3_1 = 'Super Potash 3:1'; + public const OTHER_TYPE_SUPER_POTASH_4_1 = 'Super Potash 4:1'; + public const OTHER_TYPE_SUPER_POTASH_5_1 = 'Super Potash 5:1'; + public const OTHER_TYPE_MURIATE_OF_POTASH = 'Muriate of Potash'; + public const OTHER_TYPE_SULPHATE_OF_POTASH = 'Sulphate of Potash'; + public const OTHER_TYPE_SULPHATE_OF_AMMONIA = 'Sulphate of Ammonia'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getOtherTypeAllowableValues() + { + return [ + self::OTHER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP, + self::OTHER_TYPE_DIAMMONIUM_PHOSPHATE__DAP, + self::OTHER_TYPE_UREA_AMMONIUM_NITRATE__UAN, + self::OTHER_TYPE_AMMONIUM_NITRATE__AN, + self::OTHER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN, + self::OTHER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP, + self::OTHER_TYPE_SUPER_POTASH_1_1, + self::OTHER_TYPE_SUPER_POTASH_2_1, + self::OTHER_TYPE_SUPER_POTASH_3_1, + self::OTHER_TYPE_SUPER_POTASH_4_1, + self::OTHER_TYPE_SUPER_POTASH_5_1, + self::OTHER_TYPE_MURIATE_OF_POTASH, + self::OTHER_TYPE_SULPHATE_OF_POTASH, + self::OTHER_TYPE_SULPHATE_OF_AMMONIA, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('other_type', $data ?? [], null); + $this->setIfExists('other_dryland', $data ?? [], null); + $this->setIfExists('other_irrigated', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['other_type'] === null) { + $invalidProperties[] = "'other_type' can't be null"; + } + $allowedValues = $this->getOtherTypeAllowableValues(); + if (!is_null($this->container['other_type']) && !in_array($this->container['other_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'other_type', must be one of '%s'", + $this->container['other_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['other_dryland'] === null) { + $invalidProperties[] = "'other_dryland' can't be null"; + } + if ($this->container['other_irrigated'] === null) { + $invalidProperties[] = "'other_irrigated' 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 other_type + * + * @return string + */ + public function getOtherType() + { + return $this->container['other_type']; + } + + /** + * Sets other_type + * + * @param string $other_type Other N fertiliser type + * + * @return self + */ + public function setOtherType($other_type) + { + if (is_null($other_type)) { + throw new \InvalidArgumentException('non-nullable other_type cannot be null'); + } + $allowedValues = $this->getOtherTypeAllowableValues(); + if (!in_array($other_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'other_type', must be one of '%s'", + $other_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['other_type'] = $other_type; + + return $this; + } + + /** + * Gets other_dryland + * + * @return float + */ + public function getOtherDryland() + { + return $this->container['other_dryland']; + } + + /** + * Sets other_dryland + * + * @param float $other_dryland Other N fertiliser used for dryland. From v1.1.0, supply tonnes of product. For earlier versions, supply tonnes of N + * + * @return self + */ + public function setOtherDryland($other_dryland) + { + if (is_null($other_dryland)) { + throw new \InvalidArgumentException('non-nullable other_dryland cannot be null'); + } + $this->container['other_dryland'] = $other_dryland; + + return $this; + } + + /** + * Gets other_irrigated + * + * @return float + */ + public function getOtherIrrigated() + { + return $this->container['other_irrigated']; + } + + /** + * Sets other_irrigated + * + * @param float $other_irrigated Other N fertiliser used for irrigated. From v1.1.0, supply tonnes of product. For earlier versions, supply tonnes of N + * + * @return self + */ + public function setOtherIrrigated($other_irrigated) + { + if (is_null($other_irrigated)) { + throw new \InvalidArgumentException('non-nullable other_irrigated cannot be null'); + } + $this->container['other_irrigated'] = $other_irrigated; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerMineralSupplementation.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerMineralSupplementation.php new file mode 100644 index 00000000..8e2ca08a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBeefInnerMineralSupplementation.php @@ -0,0 +1,599 @@ + + */ +class PostBeefRequestBeefInnerMineralSupplementation implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_beef_inner_mineralSupplementation'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'mineral_block' => 'float', + 'mineral_block_urea' => 'float', + 'weaner_block' => 'float', + 'weaner_block_urea' => 'float', + 'dry_season_mix' => 'float', + 'dry_season_mix_urea' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'mineral_block' => null, + 'mineral_block_urea' => null, + 'weaner_block' => null, + 'weaner_block_urea' => null, + 'dry_season_mix' => null, + 'dry_season_mix_urea' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'mineral_block' => false, + 'mineral_block_urea' => false, + 'weaner_block' => false, + 'weaner_block_urea' => false, + 'dry_season_mix' => false, + 'dry_season_mix_urea' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'mineral_block' => 'mineralBlock', + 'mineral_block_urea' => 'mineralBlockUrea', + 'weaner_block' => 'weanerBlock', + 'weaner_block_urea' => 'weanerBlockUrea', + 'dry_season_mix' => 'drySeasonMix', + 'dry_season_mix_urea' => 'drySeasonMixUrea' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'mineral_block' => 'setMineralBlock', + 'mineral_block_urea' => 'setMineralBlockUrea', + 'weaner_block' => 'setWeanerBlock', + 'weaner_block_urea' => 'setWeanerBlockUrea', + 'dry_season_mix' => 'setDrySeasonMix', + 'dry_season_mix_urea' => 'setDrySeasonMixUrea' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'mineral_block' => 'getMineralBlock', + 'mineral_block_urea' => 'getMineralBlockUrea', + 'weaner_block' => 'getWeanerBlock', + 'weaner_block_urea' => 'getWeanerBlockUrea', + 'dry_season_mix' => 'getDrySeasonMix', + 'dry_season_mix_urea' => 'getDrySeasonMixUrea' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('mineral_block', $data ?? [], 0); + $this->setIfExists('mineral_block_urea', $data ?? [], 0); + $this->setIfExists('weaner_block', $data ?? [], 0); + $this->setIfExists('weaner_block_urea', $data ?? [], 0); + $this->setIfExists('dry_season_mix', $data ?? [], 0); + $this->setIfExists('dry_season_mix_urea', $data ?? [], 0); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['mineral_block'] === null) { + $invalidProperties[] = "'mineral_block' can't be null"; + } + if ($this->container['mineral_block_urea'] === null) { + $invalidProperties[] = "'mineral_block_urea' can't be null"; + } + if ($this->container['weaner_block'] === null) { + $invalidProperties[] = "'weaner_block' can't be null"; + } + if ($this->container['weaner_block_urea'] === null) { + $invalidProperties[] = "'weaner_block_urea' can't be null"; + } + if ($this->container['dry_season_mix'] === null) { + $invalidProperties[] = "'dry_season_mix' can't be null"; + } + if ($this->container['dry_season_mix_urea'] === null) { + $invalidProperties[] = "'dry_season_mix_urea' 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 mineral_block + * + * @return float + */ + public function getMineralBlock() + { + return $this->container['mineral_block']; + } + + /** + * Sets mineral_block + * + * @param float $mineral_block Mineral block product used, in tonnes + * + * @return self + */ + public function setMineralBlock($mineral_block) + { + if (is_null($mineral_block)) { + throw new \InvalidArgumentException('non-nullable mineral_block cannot be null'); + } + $this->container['mineral_block'] = $mineral_block; + + return $this; + } + + /** + * Gets mineral_block_urea + * + * @return float + */ + public function getMineralBlockUrea() + { + return $this->container['mineral_block_urea']; + } + + /** + * Sets mineral_block_urea + * + * @param float $mineral_block_urea Fraction of urea content, between 0 and 1 + * + * @return self + */ + public function setMineralBlockUrea($mineral_block_urea) + { + if (is_null($mineral_block_urea)) { + throw new \InvalidArgumentException('non-nullable mineral_block_urea cannot be null'); + } + $this->container['mineral_block_urea'] = $mineral_block_urea; + + return $this; + } + + /** + * Gets weaner_block + * + * @return float + */ + public function getWeanerBlock() + { + return $this->container['weaner_block']; + } + + /** + * Sets weaner_block + * + * @param float $weaner_block Weaner block product used, in tonnes + * + * @return self + */ + public function setWeanerBlock($weaner_block) + { + if (is_null($weaner_block)) { + throw new \InvalidArgumentException('non-nullable weaner_block cannot be null'); + } + $this->container['weaner_block'] = $weaner_block; + + return $this; + } + + /** + * Gets weaner_block_urea + * + * @return float + */ + public function getWeanerBlockUrea() + { + return $this->container['weaner_block_urea']; + } + + /** + * Sets weaner_block_urea + * + * @param float $weaner_block_urea Fraction of urea content, between 0 and 1 + * + * @return self + */ + public function setWeanerBlockUrea($weaner_block_urea) + { + if (is_null($weaner_block_urea)) { + throw new \InvalidArgumentException('non-nullable weaner_block_urea cannot be null'); + } + $this->container['weaner_block_urea'] = $weaner_block_urea; + + return $this; + } + + /** + * Gets dry_season_mix + * + * @return float + */ + public function getDrySeasonMix() + { + return $this->container['dry_season_mix']; + } + + /** + * Sets dry_season_mix + * + * @param float $dry_season_mix Dry season mix product used, in tonnes + * + * @return self + */ + public function setDrySeasonMix($dry_season_mix) + { + if (is_null($dry_season_mix)) { + throw new \InvalidArgumentException('non-nullable dry_season_mix cannot be null'); + } + $this->container['dry_season_mix'] = $dry_season_mix; + + return $this; + } + + /** + * Gets dry_season_mix_urea + * + * @return float + */ + public function getDrySeasonMixUrea() + { + return $this->container['dry_season_mix_urea']; + } + + /** + * Sets dry_season_mix_urea + * + * @param float $dry_season_mix_urea Fraction of urea content, between 0 and 1 + * + * @return self + */ + public function setDrySeasonMixUrea($dry_season_mix_urea) + { + if (is_null($dry_season_mix_urea)) { + throw new \InvalidArgumentException('non-nullable dry_season_mix_urea cannot be null'); + } + $this->container['dry_season_mix_urea'] = $dry_season_mix_urea; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInner.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInner.php new file mode 100644 index 00000000..b7fb5fd7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInner.php @@ -0,0 +1,451 @@ + + */ +class PostBeefRequestBurningInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_burning_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'burning' => '\OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning', + 'allocation_to_beef' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'burning' => null, + 'allocation_to_beef' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'burning' => false, + 'allocation_to_beef' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'burning' => 'burning', + 'allocation_to_beef' => 'allocationToBeef' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'burning' => 'setBurning', + 'allocation_to_beef' => 'setAllocationToBeef' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'burning' => 'getBurning', + 'allocation_to_beef' => 'getAllocationToBeef' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('burning', $data ?? [], null); + $this->setIfExists('allocation_to_beef', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['burning'] === null) { + $invalidProperties[] = "'burning' can't be null"; + } + if ($this->container['allocation_to_beef'] === null) { + $invalidProperties[] = "'allocation_to_beef' 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 burning + * + * @return \OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning + */ + public function getBurning() + { + return $this->container['burning']; + } + + /** + * Sets burning + * + * @param \OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning $burning burning + * + * @return self + */ + public function setBurning($burning) + { + if (is_null($burning)) { + throw new \InvalidArgumentException('non-nullable burning cannot be null'); + } + $this->container['burning'] = $burning; + + return $this; + } + + /** + * Gets allocation_to_beef + * + * @return float[] + */ + public function getAllocationToBeef() + { + return $this->container['allocation_to_beef']; + } + + /** + * Sets allocation_to_beef + * + * @param float[] $allocation_to_beef The proportion of the burning that is allocated to each beef + * + * @return self + */ + public function setAllocationToBeef($allocation_to_beef) + { + if (is_null($allocation_to_beef)) { + throw new \InvalidArgumentException('non-nullable allocation_to_beef cannot be null'); + } + $this->container['allocation_to_beef'] = $allocation_to_beef; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInnerBurning.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInnerBurning.php new file mode 100644 index 00000000..de6b967f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestBurningInnerBurning.php @@ -0,0 +1,822 @@ + + */ +class PostBeefRequestBurningInnerBurning implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_burning_inner_burning'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel' => 'string', + 'season' => 'string', + 'patchiness' => 'string', + 'rainfall_zone' => 'string', + 'years_since_last_fire' => 'float', + 'fire_scar_area' => 'float', + 'vegetation' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel' => null, + 'season' => null, + 'patchiness' => null, + 'rainfall_zone' => null, + 'years_since_last_fire' => null, + 'fire_scar_area' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel' => false, + 'season' => false, + 'patchiness' => false, + 'rainfall_zone' => false, + 'years_since_last_fire' => false, + 'fire_scar_area' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'fuel' => 'fuel', + 'season' => 'season', + 'patchiness' => 'patchiness', + 'rainfall_zone' => 'rainfallZone', + 'years_since_last_fire' => 'yearsSinceLastFire', + 'fire_scar_area' => 'fireScarArea', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel' => 'setFuel', + 'season' => 'setSeason', + 'patchiness' => 'setPatchiness', + 'rainfall_zone' => 'setRainfallZone', + 'years_since_last_fire' => 'setYearsSinceLastFire', + 'fire_scar_area' => 'setFireScarArea', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel' => 'getFuel', + 'season' => 'getSeason', + 'patchiness' => 'getPatchiness', + 'rainfall_zone' => 'getRainfallZone', + 'years_since_last_fire' => 'getYearsSinceLastFire', + 'fire_scar_area' => 'getFireScarArea', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const FUEL_FINE = 'fine'; + public const FUEL_COARSE = 'coarse'; + public const SEASON_EARLY_DRY_SEASON = 'early dry season'; + public const SEASON_LATE_DRY_SEASON = 'late dry season'; + public const PATCHINESS_LOW = 'low'; + public const PATCHINESS_HIGH = 'high'; + public const RAINFALL_ZONE_LOW = 'low'; + public const RAINFALL_ZONE_HIGH = 'high'; + public const VEGETATION_SHRUBLAND_HUMMOCK = 'Shrubland hummock'; + public const VEGETATION_WOODLAND_HUMMOCK = 'Woodland Hummock'; + public const VEGETATION_MELALEUCA_WOODLAND = 'Melaleuca woodland'; + public const VEGETATION_WOODLAND_MIXED = 'Woodland Mixed'; + public const VEGETATION_OPEN_FOREST_MIXED = 'Open forest mixed'; + public const VEGETATION_SHRUBLAND__HEATH_WITH_HUMMOCK_GRASS = 'Shrubland (heath) with hummock grass'; + public const VEGETATION_WOODLAND_WITH_HUMMOCK_GRASS = 'Woodland with hummock grass'; + public const VEGETATION_OPEN_WOODLAND_WITH_MIXED_GRASS = 'Open woodland with mixed grass'; + public const VEGETATION_WOODLAND_WITH_MIXED_GRASS = 'Woodland with mixed grass'; + public const VEGETATION_WOODLAND_WITH_TUSSOCK_GRASS = 'Woodland with tussock grass'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getFuelAllowableValues() + { + return [ + self::FUEL_FINE, + self::FUEL_COARSE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSeasonAllowableValues() + { + return [ + self::SEASON_EARLY_DRY_SEASON, + self::SEASON_LATE_DRY_SEASON, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPatchinessAllowableValues() + { + return [ + self::PATCHINESS_LOW, + self::PATCHINESS_HIGH, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRainfallZoneAllowableValues() + { + return [ + self::RAINFALL_ZONE_LOW, + self::RAINFALL_ZONE_HIGH, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getVegetationAllowableValues() + { + return [ + self::VEGETATION_SHRUBLAND_HUMMOCK, + self::VEGETATION_WOODLAND_HUMMOCK, + self::VEGETATION_MELALEUCA_WOODLAND, + self::VEGETATION_WOODLAND_MIXED, + self::VEGETATION_OPEN_FOREST_MIXED, + self::VEGETATION_SHRUBLAND__HEATH_WITH_HUMMOCK_GRASS, + self::VEGETATION_WOODLAND_WITH_HUMMOCK_GRASS, + self::VEGETATION_OPEN_WOODLAND_WITH_MIXED_GRASS, + self::VEGETATION_WOODLAND_WITH_MIXED_GRASS, + self::VEGETATION_WOODLAND_WITH_TUSSOCK_GRASS, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel', $data ?? [], 'coarse'); + $this->setIfExists('season', $data ?? [], 'early dry season'); + $this->setIfExists('patchiness', $data ?? [], 'high'); + $this->setIfExists('rainfall_zone', $data ?? [], 'low'); + $this->setIfExists('years_since_last_fire', $data ?? [], 0); + $this->setIfExists('fire_scar_area', $data ?? [], 0); + $this->setIfExists('vegetation', $data ?? [], 'Melaleuca woodland'); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + $allowedValues = $this->getFuelAllowableValues(); + if (!is_null($this->container['fuel']) && !in_array($this->container['fuel'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'fuel', must be one of '%s'", + $this->container['fuel'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['season'] === null) { + $invalidProperties[] = "'season' can't be null"; + } + $allowedValues = $this->getSeasonAllowableValues(); + if (!is_null($this->container['season']) && !in_array($this->container['season'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'season', must be one of '%s'", + $this->container['season'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['patchiness'] === null) { + $invalidProperties[] = "'patchiness' can't be null"; + } + $allowedValues = $this->getPatchinessAllowableValues(); + if (!is_null($this->container['patchiness']) && !in_array($this->container['patchiness'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'patchiness', must be one of '%s'", + $this->container['patchiness'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_zone'] === null) { + $invalidProperties[] = "'rainfall_zone' can't be null"; + } + $allowedValues = $this->getRainfallZoneAllowableValues(); + if (!is_null($this->container['rainfall_zone']) && !in_array($this->container['rainfall_zone'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'rainfall_zone', must be one of '%s'", + $this->container['rainfall_zone'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['years_since_last_fire'] === null) { + $invalidProperties[] = "'years_since_last_fire' can't be null"; + } + if ($this->container['fire_scar_area'] === null) { + $invalidProperties[] = "'fire_scar_area' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + $allowedValues = $this->getVegetationAllowableValues(); + if (!is_null($this->container['vegetation']) && !in_array($this->container['vegetation'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'vegetation', must be one of '%s'", + $this->container['vegetation'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets fuel + * + * @return string + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param string $fuel The fuel class size that was burnt + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $allowedValues = $this->getFuelAllowableValues(); + if (!in_array($fuel, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'fuel', must be one of '%s'", + $fuel, + implode("', '", $allowedValues) + ) + ); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets season + * + * @return string + */ + public function getSeason() + { + return $this->container['season']; + } + + /** + * Sets season + * + * @param string $season The time relative to the fire season in which the burning took place + * + * @return self + */ + public function setSeason($season) + { + if (is_null($season)) { + throw new \InvalidArgumentException('non-nullable season cannot be null'); + } + $allowedValues = $this->getSeasonAllowableValues(); + if (!in_array($season, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'season', must be one of '%s'", + $season, + implode("', '", $allowedValues) + ) + ); + } + $this->container['season'] = $season; + + return $this; + } + + /** + * Gets patchiness + * + * @return string + */ + public function getPatchiness() + { + return $this->container['patchiness']; + } + + /** + * Sets patchiness + * + * @param string $patchiness The patchiness of the savannah/vegetation that was burnt + * + * @return self + */ + public function setPatchiness($patchiness) + { + if (is_null($patchiness)) { + throw new \InvalidArgumentException('non-nullable patchiness cannot be null'); + } + $allowedValues = $this->getPatchinessAllowableValues(); + if (!in_array($patchiness, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'patchiness', must be one of '%s'", + $patchiness, + implode("', '", $allowedValues) + ) + ); + } + $this->container['patchiness'] = $patchiness; + + return $this; + } + + /** + * Gets rainfall_zone + * + * @return string + */ + public function getRainfallZone() + { + return $this->container['rainfall_zone']; + } + + /** + * Sets rainfall_zone + * + * @param string $rainfall_zone The rainfall zone in which the burning took place + * + * @return self + */ + public function setRainfallZone($rainfall_zone) + { + if (is_null($rainfall_zone)) { + throw new \InvalidArgumentException('non-nullable rainfall_zone cannot be null'); + } + $allowedValues = $this->getRainfallZoneAllowableValues(); + if (!in_array($rainfall_zone, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'rainfall_zone', must be one of '%s'", + $rainfall_zone, + implode("', '", $allowedValues) + ) + ); + } + $this->container['rainfall_zone'] = $rainfall_zone; + + return $this; + } + + /** + * Gets years_since_last_fire + * + * @return float + */ + public function getYearsSinceLastFire() + { + return $this->container['years_since_last_fire']; + } + + /** + * Sets years_since_last_fire + * + * @param float $years_since_last_fire Time since the last fire, in years + * + * @return self + */ + public function setYearsSinceLastFire($years_since_last_fire) + { + if (is_null($years_since_last_fire)) { + throw new \InvalidArgumentException('non-nullable years_since_last_fire cannot be null'); + } + $this->container['years_since_last_fire'] = $years_since_last_fire; + + return $this; + } + + /** + * Gets fire_scar_area + * + * @return float + */ + public function getFireScarArea() + { + return $this->container['fire_scar_area']; + } + + /** + * Sets fire_scar_area + * + * @param float $fire_scar_area The total area of the fire scar, in ha (hectares) + * + * @return self + */ + public function setFireScarArea($fire_scar_area) + { + if (is_null($fire_scar_area)) { + throw new \InvalidArgumentException('non-nullable fire_scar_area cannot be null'); + } + $this->container['fire_scar_area'] = $fire_scar_area; + + return $this; + } + + /** + * Gets vegetation + * + * @return string + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param string $vegetation The vegetation class that was burnt + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $allowedValues = $this->getVegetationAllowableValues(); + if (!in_array($vegetation, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'vegetation', must be one of '%s'", + $vegetation, + implode("', '", $allowedValues) + ) + ); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInner.php new file mode 100644 index 00000000..4b86db68 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInner.php @@ -0,0 +1,487 @@ + + */ +class PostBeefRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'beef_proportion' => 'float', + 'allocation_to_beef' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'beef_proportion' => null, + 'allocation_to_beef' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'beef_proportion' => false, + 'allocation_to_beef' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'beef_proportion' => 'beefProportion', + 'allocation_to_beef' => 'allocationToBeef' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'beef_proportion' => 'setBeefProportion', + 'allocation_to_beef' => 'setAllocationToBeef' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'beef_proportion' => 'getBeefProportion', + 'allocation_to_beef' => 'getAllocationToBeef' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('beef_proportion', $data ?? [], null); + $this->setIfExists('allocation_to_beef', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['allocation_to_beef'] === null) { + $invalidProperties[] = "'allocation_to_beef' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets beef_proportion + * + * @return float|null + * @deprecated + */ + public function getBeefProportion() + { + return $this->container['beef_proportion']; + } + + /** + * Sets beef_proportion + * + * @param float|null $beef_proportion The proportion of the sequestration that is allocated to beef. Deprecation note: Please use `allocationToBeef` instead + * + * @return self + * @deprecated + */ + public function setBeefProportion($beef_proportion) + { + if (is_null($beef_proportion)) { + throw new \InvalidArgumentException('non-nullable beef_proportion cannot be null'); + } + $this->container['beef_proportion'] = $beef_proportion; + + return $this; + } + + /** + * Gets allocation_to_beef + * + * @return float[] + */ + public function getAllocationToBeef() + { + return $this->container['allocation_to_beef']; + } + + /** + * Sets allocation_to_beef + * + * @param float[] $allocation_to_beef The proportion of the sequestration that is allocated to each beef + * + * @return self + */ + public function setAllocationToBeef($allocation_to_beef) + { + if (is_null($allocation_to_beef)) { + throw new \InvalidArgumentException('non-nullable allocation_to_beef cannot be null'); + } + $this->container['allocation_to_beef'] = $allocation_to_beef; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInnerVegetation.php b/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInnerVegetation.php new file mode 100644 index 00000000..0e6637a9 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBeefRequestVegetationInnerVegetation.php @@ -0,0 +1,850 @@ + + */ +class PostBeefRequestVegetationInnerVegetation implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_beef_request_vegetation_inner_vegetation'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'region' => 'string', + 'tree_species' => 'string', + 'soil' => 'string', + 'area' => 'float', + 'age' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'region' => null, + 'tree_species' => null, + 'soil' => null, + 'area' => null, + 'age' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'region' => false, + 'tree_species' => false, + 'soil' => false, + 'area' => false, + 'age' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'tree_species' => 'treeSpecies', + 'soil' => 'soil', + 'area' => 'area', + 'age' => 'age' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'region' => 'setRegion', + 'tree_species' => 'setTreeSpecies', + 'soil' => 'setSoil', + 'area' => 'setArea', + 'age' => 'setAge' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'region' => 'getRegion', + 'tree_species' => 'getTreeSpecies', + 'soil' => 'getSoil', + 'area' => 'getArea', + 'age' => 'getAge' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const REGION_SOUTH_WEST = 'South West'; + public const REGION_PILBARA = 'Pilbara'; + public const REGION_KIMBERLEY = 'Kimberley'; + public const REGION_CENTRAL_WEST = 'Central West'; + public const REGION_SOUTH_COASTAL = 'South Coastal'; + public const REGION_GOLDFIELDS_EUCLA = 'Goldfields/Eucla'; + public const REGION_GASCOYNE = 'Gascoyne'; + public const REGION_CENTRAL_WHEAT_BELT = 'Central Wheat Belt'; + public const REGION_INTERIOR = 'Interior'; + public const REGION_NORTH_COAST = 'North Coast'; + public const REGION_SOUTH_COAST = 'South Coast'; + public const REGION_NORTHERN_TABLELANDS = 'Northern Tablelands'; + public const REGION_SOUTHERN_TABLELANDS = 'Southern Tablelands'; + public const REGION_NORTHERN_WHEAT_SHEEP = 'Northern Wheat/Sheep'; + public const REGION_SOUTHERN_WHEAT_SHEEP = 'Southern Wheat/Sheep'; + public const REGION_WESTERN = 'Western'; + public const REGION_NORTH_EAST = 'North East'; + public const REGION_EAST_COAST = 'East Coast'; + public const REGION_CENTRAL_NORTH_MIDLANDS_SOUTH_EAST = 'Central North/Midlands/South East'; + public const REGION_CENTRAL_PLATEAU_DERWENT_VALLEY = 'Central Plateau/Derwent Valley'; + public const REGION_WEST_SOUTH_COAST = 'West/South Coast'; + public const REGION_NORTH_WEST = 'North West'; + public const REGION_SOUTH_EAST = 'South East'; + public const REGION_MURRAY = 'Murray'; + public const REGION_MID_NORTH_FLINDERS = 'Mid-North/Flinders'; + public const REGION_PASTORAL = 'Pastoral'; + public const REGION_WEST_COAST_EYRE = 'West Coast/Eyre'; + public const REGION_MALLEE = 'Mallee'; + public const REGION_WIMMERA = 'Wimmera'; + public const REGION_NORTHERN_COUNTRY = 'Northern Country'; + public const REGION_NORTH_EAST_VIC = 'North East Vic'; + public const REGION_EAST_GIPPSLAND = 'East Gippsland'; + public const REGION_WEST_SOUTH_GIPPSLAND = 'West/South Gippsland'; + public const REGION_CENTRAL = 'Central'; + public const REGION_SOUTH_WEST_VIC = 'South West Vic'; + public const REGION_CENTRAL_HIGHLANDS_NORTHERN = 'Central Highlands/Northern'; + public const REGION_CENTRAL_WEST_FLINDERS = 'Central West/Flinders'; + public const REGION_CHANNEL_COUNTRY = 'Channel Country'; + public const REGION_MARANOA_WARREGO = 'Maranoa/Warrego'; + public const REGION_DARLING_DOWNS_BURNETT = 'Darling Downs/Burnett'; + public const REGION_NORTH_WEST_GULF = 'North West/Gulf'; + public const REGION_DARWIN_DALY = 'Darwin-Daly'; + public const REGION_ARNHEM_ROPER = 'Arnhem-Roper'; + public const REGION_VICTORIA_RIVER_TENNANT_CREEK = 'Victoria River-TennantCreek'; + public const REGION_ALICE_SPRINGS = 'Alice Springs'; + public const TREE_SPECIES_MIXED_SPECIES__ENVIRONMENTAL_PLANTINGS = 'Mixed species (Environmental Plantings)'; + public const TREE_SPECIES_NO_TREE_DATA_AVAILABLE = 'No tree data available'; + public const TREE_SPECIES_TASMANIAN_BLUE_GUM = 'Tasmanian Blue Gum'; + public const TREE_SPECIES_SPOTTED_GUM = 'Spotted Gum'; + public const TREE_SPECIES_SUGAR_GUM = 'Sugar Gum'; + public const TREE_SPECIES_HOOP_PINE = 'Hoop Pine'; + public const TREE_SPECIES_SYDNEY_BLUE_GUM = 'Sydney Blue Gum'; + public const TREE_SPECIES_DUNNS_WHITE_GUM = 'Dunn\'s White Gum'; + public const TREE_SPECIES_SHINING_GUM = 'Shining Gum'; + public const TREE_SPECIES_PINUS_RADIATA = 'Pinus Radiata'; + public const TREE_SPECIES_LEMON_SCENTED_GUM = 'Lemon-scented Gum'; + public const TREE_SPECIES_MARITIME_PINE = 'Maritime Pine'; + public const TREE_SPECIES_FLOODED_GUM = 'Flooded Gum'; + public const TREE_SPECIES_RED_IRONBARK = 'Red Ironbark'; + public const TREE_SPECIES_RADIATA_PINE__LOW_INPUT = 'Radiata Pine (low input)'; + public const TREE_SPECIES_MOUNTAIN_ASH = 'Mountain Ash'; + public const TREE_SPECIES_WESTERN_WHITE_GUM = 'Western White Gum'; + public const TREE_SPECIES_SLASH_PINE = 'Slash Pine'; + public const TREE_SPECIES_RADIATA_PINE__HIGH_INPUT = 'Radiata Pine (high input)'; + public const TREE_SPECIES_PINUS_RADIATA__LOW_INPUT = 'Pinus Radiata (low input)'; + public const TREE_SPECIES_BLACKBUTT = 'Blackbutt'; + public const TREE_SPECIES_LOBLOLLY_PINE = 'Loblolly Pine'; + public const TREE_SPECIES_PINUS_RADIATA__HIGH_INPUT = 'Pinus Radiata (high input)'; + public const TREE_SPECIES_PINUS_HYBRIDS = 'Pinus Hybrids'; + public const SOIL_LOAMS__CLAYS = 'Loams & Clays'; + public const SOIL_NO_SOIL___TREE_DATA_AVAILABLE = 'No Soil / Tree data available'; + public const SOIL_COLOURED_SANDS = 'Coloured Sands'; + public const SOIL_DUPLEX = 'Duplex'; + public const SOIL_CLAY = 'Clay'; + public const SOIL_OTHER_SOILS = '"Other Soils"'; + public const SOIL_OTHER_SOILS2 = 'Other Soils'; + public const SOIL_DUPLEX_SOILS = 'Duplex Soils'; + public const SOIL_SANDY_SOILS = 'Sandy Soils'; + public const SOIL_CALCAROSOLS = 'Calcarosols'; + public const SOIL_GREY_CRACKING_CLAYS = 'Grey Cracking Clays'; + public const SOIL_RED_EARTHS = 'Red Earths'; + public const SOIL_NON_CRACKING_CLAYS = 'Non-cracking Clays'; + public const SOIL_RED_DUPLEX = 'Red Duplex'; + public const SOIL_CRACKING_CLAYS = 'Cracking Clays'; + public const SOIL_CLAYS = 'Clays'; + public const SOIL_CLAY_GIDGEE = 'Clay Gidgee'; + public const SOIL_CLAY__BRIGALO_AND_BELAH = 'Clay (Brigalo and Belah)'; + public const SOIL_KANDOSOLS = 'Kandosols'; + public const SOIL_SANDY_DUPLEXES = 'Sandy Duplexes'; + public const SOIL_CLAY__RED_LOAM = 'Clay & Red Loam'; + public const SOIL_LOAM = 'Loam'; + public const SOIL_STRUCTURED_EARTHS = 'Structured Earths'; + public const SOIL_LOAMY_SOILS = 'Loamy Soils'; + public const SOIL_YELLOW_DUPLEX = 'Yellow Duplex'; + public const SOIL_GRADATIONAL_SOILS = 'Gradational soils'; + public const SOIL_OPEN_DOWNS = 'Open Downs'; + public const SOIL_DUPLEX_WOODLAND = 'Duplex Woodland'; + public const SOIL_EARTHS = 'Earths'; + public const SOIL_TENOSOLS = 'Tenosols'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRegionAllowableValues() + { + return [ + self::REGION_SOUTH_WEST, + self::REGION_PILBARA, + self::REGION_KIMBERLEY, + self::REGION_CENTRAL_WEST, + self::REGION_SOUTH_COASTAL, + self::REGION_GOLDFIELDS_EUCLA, + self::REGION_GASCOYNE, + self::REGION_CENTRAL_WHEAT_BELT, + self::REGION_INTERIOR, + self::REGION_NORTH_COAST, + self::REGION_SOUTH_COAST, + self::REGION_NORTHERN_TABLELANDS, + self::REGION_SOUTHERN_TABLELANDS, + self::REGION_NORTHERN_WHEAT_SHEEP, + self::REGION_SOUTHERN_WHEAT_SHEEP, + self::REGION_WESTERN, + self::REGION_NORTH_EAST, + self::REGION_EAST_COAST, + self::REGION_CENTRAL_NORTH_MIDLANDS_SOUTH_EAST, + self::REGION_CENTRAL_PLATEAU_DERWENT_VALLEY, + self::REGION_WEST_SOUTH_COAST, + self::REGION_NORTH_WEST, + self::REGION_SOUTH_EAST, + self::REGION_MURRAY, + self::REGION_MID_NORTH_FLINDERS, + self::REGION_PASTORAL, + self::REGION_WEST_COAST_EYRE, + self::REGION_MALLEE, + self::REGION_WIMMERA, + self::REGION_NORTHERN_COUNTRY, + self::REGION_NORTH_EAST_VIC, + self::REGION_EAST_GIPPSLAND, + self::REGION_WEST_SOUTH_GIPPSLAND, + self::REGION_CENTRAL, + self::REGION_SOUTH_WEST_VIC, + self::REGION_CENTRAL_HIGHLANDS_NORTHERN, + self::REGION_CENTRAL_WEST_FLINDERS, + self::REGION_CHANNEL_COUNTRY, + self::REGION_MARANOA_WARREGO, + self::REGION_DARLING_DOWNS_BURNETT, + self::REGION_NORTH_WEST_GULF, + self::REGION_DARWIN_DALY, + self::REGION_ARNHEM_ROPER, + self::REGION_VICTORIA_RIVER_TENNANT_CREEK, + self::REGION_ALICE_SPRINGS, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTreeSpeciesAllowableValues() + { + return [ + self::TREE_SPECIES_MIXED_SPECIES__ENVIRONMENTAL_PLANTINGS, + self::TREE_SPECIES_NO_TREE_DATA_AVAILABLE, + self::TREE_SPECIES_TASMANIAN_BLUE_GUM, + self::TREE_SPECIES_SPOTTED_GUM, + self::TREE_SPECIES_SUGAR_GUM, + self::TREE_SPECIES_HOOP_PINE, + self::TREE_SPECIES_SYDNEY_BLUE_GUM, + self::TREE_SPECIES_DUNNS_WHITE_GUM, + self::TREE_SPECIES_SHINING_GUM, + self::TREE_SPECIES_PINUS_RADIATA, + self::TREE_SPECIES_LEMON_SCENTED_GUM, + self::TREE_SPECIES_MARITIME_PINE, + self::TREE_SPECIES_FLOODED_GUM, + self::TREE_SPECIES_RED_IRONBARK, + self::TREE_SPECIES_RADIATA_PINE__LOW_INPUT, + self::TREE_SPECIES_MOUNTAIN_ASH, + self::TREE_SPECIES_WESTERN_WHITE_GUM, + self::TREE_SPECIES_SLASH_PINE, + self::TREE_SPECIES_RADIATA_PINE__HIGH_INPUT, + self::TREE_SPECIES_PINUS_RADIATA__LOW_INPUT, + self::TREE_SPECIES_BLACKBUTT, + self::TREE_SPECIES_LOBLOLLY_PINE, + self::TREE_SPECIES_PINUS_RADIATA__HIGH_INPUT, + self::TREE_SPECIES_PINUS_HYBRIDS, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSoilAllowableValues() + { + return [ + self::SOIL_LOAMS__CLAYS, + self::SOIL_NO_SOIL___TREE_DATA_AVAILABLE, + self::SOIL_COLOURED_SANDS, + self::SOIL_DUPLEX, + self::SOIL_CLAY, + self::SOIL_OTHER_SOILS, + self::SOIL_OTHER_SOILS2, + self::SOIL_DUPLEX_SOILS, + self::SOIL_SANDY_SOILS, + self::SOIL_CALCAROSOLS, + self::SOIL_GREY_CRACKING_CLAYS, + self::SOIL_RED_EARTHS, + self::SOIL_NON_CRACKING_CLAYS, + self::SOIL_RED_DUPLEX, + self::SOIL_CRACKING_CLAYS, + self::SOIL_CLAYS, + self::SOIL_CLAY_GIDGEE, + self::SOIL_CLAY__BRIGALO_AND_BELAH, + self::SOIL_KANDOSOLS, + self::SOIL_SANDY_DUPLEXES, + self::SOIL_CLAY__RED_LOAM, + self::SOIL_LOAM, + self::SOIL_STRUCTURED_EARTHS, + self::SOIL_LOAMY_SOILS, + self::SOIL_YELLOW_DUPLEX, + self::SOIL_GRADATIONAL_SOILS, + self::SOIL_OPEN_DOWNS, + self::SOIL_DUPLEX_WOODLAND, + self::SOIL_EARTHS, + self::SOIL_TENOSOLS, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('region', $data ?? [], null); + $this->setIfExists('tree_species', $data ?? [], null); + $this->setIfExists('soil', $data ?? [], null); + $this->setIfExists('area', $data ?? [], null); + $this->setIfExists('age', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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'] === null) { + $invalidProperties[] = "'region' can't be null"; + } + $allowedValues = $this->getRegionAllowableValues(); + if (!is_null($this->container['region']) && !in_array($this->container['region'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'region', must be one of '%s'", + $this->container['region'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['tree_species'] === null) { + $invalidProperties[] = "'tree_species' can't be null"; + } + $allowedValues = $this->getTreeSpeciesAllowableValues(); + if (!is_null($this->container['tree_species']) && !in_array($this->container['tree_species'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'tree_species', must be one of '%s'", + $this->container['tree_species'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['soil'] === null) { + $invalidProperties[] = "'soil' can't be null"; + } + $allowedValues = $this->getSoilAllowableValues(); + if (!is_null($this->container['soil']) && !in_array($this->container['soil'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'soil', must be one of '%s'", + $this->container['soil'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['area'] === null) { + $invalidProperties[] = "'area' can't be null"; + } + if ($this->container['age'] === null) { + $invalidProperties[] = "'age' 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 region + * + * @return string + */ + public function getRegion() + { + return $this->container['region']; + } + + /** + * Sets region + * + * @param string $region The rainfall region that the vegetation is in + * + * @return self + */ + public function setRegion($region) + { + if (is_null($region)) { + throw new \InvalidArgumentException('non-nullable region cannot be null'); + } + $allowedValues = $this->getRegionAllowableValues(); + if (!in_array($region, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'region', must be one of '%s'", + $region, + implode("', '", $allowedValues) + ) + ); + } + $this->container['region'] = $region; + + return $this; + } + + /** + * Gets tree_species + * + * @return string + */ + public function getTreeSpecies() + { + return $this->container['tree_species']; + } + + /** + * Sets tree_species + * + * @param string $tree_species The species of tree + * + * @return self + */ + public function setTreeSpecies($tree_species) + { + if (is_null($tree_species)) { + throw new \InvalidArgumentException('non-nullable tree_species cannot be null'); + } + $allowedValues = $this->getTreeSpeciesAllowableValues(); + if (!in_array($tree_species, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'tree_species', must be one of '%s'", + $tree_species, + implode("', '", $allowedValues) + ) + ); + } + $this->container['tree_species'] = $tree_species; + + return $this; + } + + /** + * Gets soil + * + * @return string + */ + public function getSoil() + { + return $this->container['soil']; + } + + /** + * Sets soil + * + * @param string $soil The soil type the tree is in + * + * @return self + */ + public function setSoil($soil) + { + if (is_null($soil)) { + throw new \InvalidArgumentException('non-nullable soil cannot be null'); + } + $allowedValues = $this->getSoilAllowableValues(); + if (!in_array($soil, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'soil', must be one of '%s'", + $soil, + implode("', '", $allowedValues) + ) + ); + } + $this->container['soil'] = $soil; + + return $this; + } + + /** + * Gets area + * + * @return float + */ + public function getArea() + { + return $this->container['area']; + } + + /** + * Sets area + * + * @param float $area The area of trees, in ha (hectares) + * + * @return self + */ + public function setArea($area) + { + if (is_null($area)) { + throw new \InvalidArgumentException('non-nullable area cannot be null'); + } + $this->container['area'] = $area; + + return $this; + } + + /** + * Gets age + * + * @return float + */ + public function getAge() + { + return $this->container['age']; + } + + /** + * Sets age + * + * @param float $age The age of the trees, in years + * + * @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; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200Response.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200Response.php new file mode 100644 index 00000000..ffbfc0a0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200Response.php @@ -0,0 +1,636 @@ + + */ +class PostBuffalo200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostBuffalo200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostBuffalo200ResponseIntensities', + 'intermediate' => '\OpenAPI\Client\Model\PostBuffalo200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntensities.php new file mode 100644 index 00000000..be6e7d1e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostBuffalo200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'liveweight_produced_kg' => 'float', + 'buffalo_meat_excluding_sequestration' => 'float', + 'buffalo_meat_including_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'liveweight_produced_kg' => null, + 'buffalo_meat_excluding_sequestration' => null, + 'buffalo_meat_including_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'liveweight_produced_kg' => false, + 'buffalo_meat_excluding_sequestration' => false, + 'buffalo_meat_including_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'liveweight_produced_kg' => 'liveweightProducedKg', + 'buffalo_meat_excluding_sequestration' => 'buffaloMeatExcludingSequestration', + 'buffalo_meat_including_sequestration' => 'buffaloMeatIncludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'liveweight_produced_kg' => 'setLiveweightProducedKg', + 'buffalo_meat_excluding_sequestration' => 'setBuffaloMeatExcludingSequestration', + 'buffalo_meat_including_sequestration' => 'setBuffaloMeatIncludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'liveweight_produced_kg' => 'getLiveweightProducedKg', + 'buffalo_meat_excluding_sequestration' => 'getBuffaloMeatExcludingSequestration', + 'buffalo_meat_including_sequestration' => 'getBuffaloMeatIncludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('liveweight_produced_kg', $data ?? [], null); + $this->setIfExists('buffalo_meat_excluding_sequestration', $data ?? [], null); + $this->setIfExists('buffalo_meat_including_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['liveweight_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_produced_kg' can't be null"; + } + if ($this->container['buffalo_meat_excluding_sequestration'] === null) { + $invalidProperties[] = "'buffalo_meat_excluding_sequestration' can't be null"; + } + if ($this->container['buffalo_meat_including_sequestration'] === null) { + $invalidProperties[] = "'buffalo_meat_including_sequestration' 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 liveweight_produced_kg + * + * @return float + */ + public function getLiveweightProducedKg() + { + return $this->container['liveweight_produced_kg']; + } + + /** + * Sets liveweight_produced_kg + * + * @param float $liveweight_produced_kg Amount of buffalo meat produced in kg liveweight + * + * @return self + */ + public function setLiveweightProducedKg($liveweight_produced_kg) + { + if (is_null($liveweight_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_produced_kg cannot be null'); + } + $this->container['liveweight_produced_kg'] = $liveweight_produced_kg; + + return $this; + } + + /** + * Gets buffalo_meat_excluding_sequestration + * + * @return float + */ + public function getBuffaloMeatExcludingSequestration() + { + return $this->container['buffalo_meat_excluding_sequestration']; + } + + /** + * Sets buffalo_meat_excluding_sequestration + * + * @param float $buffalo_meat_excluding_sequestration Buffalo meat (breeding herd) excluding sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBuffaloMeatExcludingSequestration($buffalo_meat_excluding_sequestration) + { + if (is_null($buffalo_meat_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable buffalo_meat_excluding_sequestration cannot be null'); + } + $this->container['buffalo_meat_excluding_sequestration'] = $buffalo_meat_excluding_sequestration; + + return $this; + } + + /** + * Gets buffalo_meat_including_sequestration + * + * @return float + */ + public function getBuffaloMeatIncludingSequestration() + { + return $this->container['buffalo_meat_including_sequestration']; + } + + /** + * Sets buffalo_meat_including_sequestration + * + * @param float $buffalo_meat_including_sequestration Buffalo meat (breeding herd) including sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBuffaloMeatIncludingSequestration($buffalo_meat_including_sequestration) + { + if (is_null($buffalo_meat_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable buffalo_meat_including_sequestration cannot be null'); + } + $this->container['buffalo_meat_including_sequestration'] = $buffalo_meat_including_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntermediateInner.php new file mode 100644 index 00000000..5e1af3a5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostBuffalo200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope3', + 'net' => '\OpenAPI\Client\Model\PostBuffalo200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostBuffalo200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseNet.php new file mode 100644 index 00000000..b8b436e3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostBuffalo200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope1.php new file mode 100644 index 00000000..b128bed9 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope1.php @@ -0,0 +1,932 @@ + + */ +class PostBuffalo200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'fertiliser_n2_o' => 'float', + 'enteric_ch4' => 'float', + 'manure_management_ch4' => 'float', + 'urine_and_dung_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'fertiliser_n2_o' => null, + 'enteric_ch4' => null, + 'manure_management_ch4' => null, + 'urine_and_dung_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'fertiliser_n2_o' => false, + 'enteric_ch4' => false, + 'manure_management_ch4' => false, + 'urine_and_dung_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'enteric_ch4' => 'entericCH4', + 'manure_management_ch4' => 'manureManagementCH4', + 'urine_and_dung_n2_o' => 'urineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'enteric_ch4' => 'setEntericCh4', + 'manure_management_ch4' => 'setManureManagementCh4', + 'urine_and_dung_n2_o' => 'setUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'enteric_ch4' => 'getEntericCh4', + 'manure_management_ch4' => 'getManureManagementCh4', + 'urine_and_dung_n2_o' => 'getUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('enteric_ch4', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('urine_and_dung_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['enteric_ch4'] === null) { + $invalidProperties[] = "'enteric_ch4' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['urine_and_dung_n2_o'] === null) { + $invalidProperties[] = "'urine_and_dung_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets enteric_ch4 + * + * @return float + */ + public function getEntericCh4() + { + return $this->container['enteric_ch4']; + } + + /** + * Sets enteric_ch4 + * + * @param float $enteric_ch4 CH4 emissions from enteric fermentation, in tonnes-CO2e + * + * @return self + */ + public function setEntericCh4($enteric_ch4) + { + if (is_null($enteric_ch4)) { + throw new \InvalidArgumentException('non-nullable enteric_ch4 cannot be null'); + } + $this->container['enteric_ch4'] = $enteric_ch4; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets urine_and_dung_n2_o + * + * @return float + */ + public function getUrineAndDungN2O() + { + return $this->container['urine_and_dung_n2_o']; + } + + /** + * Sets urine_and_dung_n2_o + * + * @param float $urine_and_dung_n2_o N2O emissions from urine and dung, in tonnes-CO2e + * + * @return self + */ + public function setUrineAndDungN2O($urine_and_dung_n2_o) + { + if (is_null($urine_and_dung_n2_o)) { + throw new \InvalidArgumentException('non-nullable urine_and_dung_n2_o cannot be null'); + } + $this->container['urine_and_dung_n2_o'] = $urine_and_dung_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope3.php new file mode 100644 index 00000000..4780ab63 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffalo200ResponseScope3.php @@ -0,0 +1,673 @@ + + */ +class PostBuffalo200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'purchased_feed' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'purchased_livestock' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'purchased_feed' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'purchased_livestock' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'purchased_feed' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => false, + 'purchased_livestock' => 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 = [ + 'fertiliser' => 'fertiliser', + 'purchased_feed' => 'purchasedFeed', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'purchased_livestock' => 'purchasedLivestock', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'purchased_feed' => 'setPurchasedFeed', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'purchased_livestock' => 'setPurchasedLivestock', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'purchased_feed' => 'getPurchasedFeed', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + 'purchased_livestock' => 'getPurchasedLivestock', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('purchased_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $data ?? [], null); + $this->setIfExists('purchased_livestock', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['purchased_feed'] === null) { + $invalidProperties[] = "'purchased_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['purchased_livestock'] === null) { + $invalidProperties[] = "'purchased_livestock' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets purchased_feed + * + * @return float + */ + public function getPurchasedFeed() + { + return $this->container['purchased_feed']; + } + + /** + * Sets purchased_feed + * + * @param float $purchased_feed Emissions from purchased feed, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedFeed($purchased_feed) + { + if (is_null($purchased_feed)) { + throw new \InvalidArgumentException('non-nullable purchased_feed cannot be null'); + } + $this->container['purchased_feed'] = $purchased_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets purchased_livestock + * + * @return float + */ + public function getPurchasedLivestock() + { + return $this->container['purchased_livestock']; + } + + /** + * Sets purchased_livestock + * + * @param float $purchased_livestock Emissions from purchased livestock, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedLivestock($purchased_livestock) + { + if (is_null($purchased_livestock)) { + throw new \InvalidArgumentException('non-nullable purchased_livestock cannot be null'); + } + $this->container['purchased_livestock'] = $purchased_livestock; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequest.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequest.php new file mode 100644 index 00000000..f330ebd7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequest.php @@ -0,0 +1,573 @@ + + */ +class PostBuffaloRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'rainfall_above600' => 'bool', + 'buffalos' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostBuffaloRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'rainfall_above600' => null, + 'buffalos' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'rainfall_above600' => false, + 'buffalos' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'rainfall_above600' => 'rainfallAbove600', + 'buffalos' => 'buffalos', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'rainfall_above600' => 'setRainfallAbove600', + 'buffalos' => 'setBuffalos', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'rainfall_above600' => 'getRainfallAbove600', + 'buffalos' => 'getBuffalos', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('buffalos', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['buffalos'] === null) { + $invalidProperties[] = "'buffalos' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets buffalos + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInner[] + */ + public function getBuffalos() + { + return $this->container['buffalos']; + } + + /** + * Sets buffalos + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInner[] $buffalos buffalos + * + * @return self + */ + public function setBuffalos($buffalos) + { + if (is_null($buffalos)) { + throw new \InvalidArgumentException('non-nullable buffalos cannot be null'); + } + $this->container['buffalos'] = $buffalos; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInner.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInner.php new file mode 100644 index 00000000..2babd0cc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInner.php @@ -0,0 +1,1052 @@ + + */ +class PostBuffaloRequestBuffalosInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'cows_calving' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerCowsCalving', + 'seasonal_calving' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerSeasonalCalving' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'cows_calving' => null, + 'seasonal_calving' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'cows_calving' => false, + 'seasonal_calving' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'cows_calving' => 'cowsCalving', + 'seasonal_calving' => 'seasonalCalving' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'cows_calving' => 'setCowsCalving', + 'seasonal_calving' => 'setSeasonalCalving' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'cows_calving' => 'getCowsCalving', + 'seasonal_calving' => 'getSeasonalCalving' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('cows_calving', $data ?? [], null); + $this->setIfExists('seasonal_calving', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['cows_calving'] === null) { + $invalidProperties[] = "'cows_calving' can't be null"; + } + if ($this->container['seasonal_calving'] === null) { + $invalidProperties[] = "'seasonal_calving' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostBuffaloRequestBuffalosInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostBuffaloRequestBuffalosInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets cows_calving + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerCowsCalving + */ + public function getCowsCalving() + { + return $this->container['cows_calving']; + } + + /** + * Sets cows_calving + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerCowsCalving $cows_calving cows_calving + * + * @return self + */ + public function setCowsCalving($cows_calving) + { + if (is_null($cows_calving)) { + throw new \InvalidArgumentException('non-nullable cows_calving cannot be null'); + } + $this->container['cows_calving'] = $cows_calving; + + return $this; + } + + /** + * Gets seasonal_calving + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerSeasonalCalving + */ + public function getSeasonalCalving() + { + return $this->container['seasonal_calving']; + } + + /** + * Sets seasonal_calving + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerSeasonalCalving $seasonal_calving seasonal_calving + * + * @return self + */ + public function setSeasonalCalving($seasonal_calving) + { + if (is_null($seasonal_calving)) { + throw new \InvalidArgumentException('non-nullable seasonal_calving cannot be null'); + } + $this->container['seasonal_calving'] = $seasonal_calving; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClasses.php new file mode 100644 index 00000000..27910883 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClasses.php @@ -0,0 +1,649 @@ + + */ +class PostBuffaloRequestBuffalosInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bulls' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBulls', + 'trade_bulls' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeBulls', + 'cows' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCows', + 'trade_cows' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCows', + 'steers' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesSteers', + 'trade_steers' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeSteers', + 'calfs' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCalfs', + 'trade_calfs' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCalfs' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bulls' => null, + 'trade_bulls' => null, + 'cows' => null, + 'trade_cows' => null, + 'steers' => null, + 'trade_steers' => null, + 'calfs' => null, + 'trade_calfs' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bulls' => false, + 'trade_bulls' => false, + 'cows' => false, + 'trade_cows' => false, + 'steers' => false, + 'trade_steers' => false, + 'calfs' => false, + 'trade_calfs' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bulls' => 'bulls', + 'trade_bulls' => 'tradeBulls', + 'cows' => 'cows', + 'trade_cows' => 'tradeCows', + 'steers' => 'steers', + 'trade_steers' => 'tradeSteers', + 'calfs' => 'calfs', + 'trade_calfs' => 'tradeCalfs' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bulls' => 'setBulls', + 'trade_bulls' => 'setTradeBulls', + 'cows' => 'setCows', + 'trade_cows' => 'setTradeCows', + 'steers' => 'setSteers', + 'trade_steers' => 'setTradeSteers', + 'calfs' => 'setCalfs', + 'trade_calfs' => 'setTradeCalfs' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bulls' => 'getBulls', + 'trade_bulls' => 'getTradeBulls', + 'cows' => 'getCows', + 'trade_cows' => 'getTradeCows', + 'steers' => 'getSteers', + 'trade_steers' => 'getTradeSteers', + 'calfs' => 'getCalfs', + 'trade_calfs' => 'getTradeCalfs' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bulls', $data ?? [], null); + $this->setIfExists('trade_bulls', $data ?? [], null); + $this->setIfExists('cows', $data ?? [], null); + $this->setIfExists('trade_cows', $data ?? [], null); + $this->setIfExists('steers', $data ?? [], null); + $this->setIfExists('trade_steers', $data ?? [], null); + $this->setIfExists('calfs', $data ?? [], null); + $this->setIfExists('trade_calfs', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 bulls + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBulls|null + */ + public function getBulls() + { + return $this->container['bulls']; + } + + /** + * Sets bulls + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBulls|null $bulls bulls + * + * @return self + */ + public function setBulls($bulls) + { + if (is_null($bulls)) { + throw new \InvalidArgumentException('non-nullable bulls cannot be null'); + } + $this->container['bulls'] = $bulls; + + return $this; + } + + /** + * Gets trade_bulls + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeBulls|null + */ + public function getTradeBulls() + { + return $this->container['trade_bulls']; + } + + /** + * Sets trade_bulls + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeBulls|null $trade_bulls trade_bulls + * + * @return self + */ + public function setTradeBulls($trade_bulls) + { + if (is_null($trade_bulls)) { + throw new \InvalidArgumentException('non-nullable trade_bulls cannot be null'); + } + $this->container['trade_bulls'] = $trade_bulls; + + return $this; + } + + /** + * Gets cows + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCows|null + */ + public function getCows() + { + return $this->container['cows']; + } + + /** + * Sets cows + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCows|null $cows cows + * + * @return self + */ + public function setCows($cows) + { + if (is_null($cows)) { + throw new \InvalidArgumentException('non-nullable cows cannot be null'); + } + $this->container['cows'] = $cows; + + return $this; + } + + /** + * Gets trade_cows + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCows|null + */ + public function getTradeCows() + { + return $this->container['trade_cows']; + } + + /** + * Sets trade_cows + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCows|null $trade_cows trade_cows + * + * @return self + */ + public function setTradeCows($trade_cows) + { + if (is_null($trade_cows)) { + throw new \InvalidArgumentException('non-nullable trade_cows cannot be null'); + } + $this->container['trade_cows'] = $trade_cows; + + return $this; + } + + /** + * Gets steers + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesSteers|null + */ + public function getSteers() + { + return $this->container['steers']; + } + + /** + * Sets steers + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesSteers|null $steers steers + * + * @return self + */ + public function setSteers($steers) + { + if (is_null($steers)) { + throw new \InvalidArgumentException('non-nullable steers cannot be null'); + } + $this->container['steers'] = $steers; + + return $this; + } + + /** + * Gets trade_steers + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeSteers|null + */ + public function getTradeSteers() + { + return $this->container['trade_steers']; + } + + /** + * Sets trade_steers + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeSteers|null $trade_steers trade_steers + * + * @return self + */ + public function setTradeSteers($trade_steers) + { + if (is_null($trade_steers)) { + throw new \InvalidArgumentException('non-nullable trade_steers cannot be null'); + } + $this->container['trade_steers'] = $trade_steers; + + return $this; + } + + /** + * Gets calfs + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCalfs|null + */ + public function getCalfs() + { + return $this->container['calfs']; + } + + /** + * Sets calfs + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesCalfs|null $calfs calfs + * + * @return self + */ + public function setCalfs($calfs) + { + if (is_null($calfs)) { + throw new \InvalidArgumentException('non-nullable calfs cannot be null'); + } + $this->container['calfs'] = $calfs; + + return $this; + } + + /** + * Gets trade_calfs + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCalfs|null + */ + public function getTradeCalfs() + { + return $this->container['trade_calfs']; + } + + /** + * Sets trade_calfs + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesTradeCalfs|null $trade_calfs trade_calfs + * + * @return self + */ + public function setTradeCalfs($trade_calfs) + { + if (is_null($trade_calfs)) { + throw new \InvalidArgumentException('non-nullable trade_calfs cannot be null'); + } + $this->container['trade_calfs'] = $trade_calfs; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBulls.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBulls.php new file mode 100644 index 00000000..94f9a5fe --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBulls.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesBulls implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_bulls'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.php new file mode 100644 index 00000000..17b0f558 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.php @@ -0,0 +1,413 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesBullsAutumn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_bulls_autumn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' 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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.php new file mode 100644 index 00000000..282437a0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.php @@ -0,0 +1,450 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_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 = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCalfs.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCalfs.php new file mode 100644 index 00000000..931337ee --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCalfs.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesCalfs implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_calfs'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCows.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCows.php new file mode 100644 index 00000000..5adf938d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesCows.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesCows implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_cows'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesSteers.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesSteers.php new file mode 100644 index 00000000..49458b5d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesSteers.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesSteers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_steers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeBulls.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeBulls.php new file mode 100644 index 00000000..df7b0652 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeBulls.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesTradeBulls implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_tradeBulls'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.php new file mode 100644 index 00000000..791cdaec --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesTradeCalfs implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_tradeCalfs'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCows.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCows.php new file mode 100644 index 00000000..b624a1a4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeCows.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesTradeCows implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_tradeCows'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeSteers.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeSteers.php new file mode 100644 index 00000000..01550d70 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerClassesTradeSteers.php @@ -0,0 +1,633 @@ + + */ +class PostBuffaloRequestBuffalosInnerClassesTradeSteers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_classes_tradeSteers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerCowsCalving.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerCowsCalving.php new file mode 100644 index 00000000..570b5918 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerCowsCalving.php @@ -0,0 +1,525 @@ + + */ +class PostBuffaloRequestBuffalosInnerCowsCalving implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_cowsCalving'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => 'float', + 'summer' => 'float', + 'autumn' => 'float', + 'winter' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerSeasonalCalving.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerSeasonalCalving.php new file mode 100644 index 00000000..ba4074b1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestBuffalosInnerSeasonalCalving.php @@ -0,0 +1,525 @@ + + */ +class PostBuffaloRequestBuffalosInnerSeasonalCalving implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_buffalos_inner_seasonalCalving'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => 'float', + 'summer' => 'float', + 'autumn' => 'float', + 'winter' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestVegetationInner.php new file mode 100644 index 00000000..8f43b1f0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostBuffaloRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostBuffaloRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_buffalo_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'buffalo_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'buffalo_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'buffalo_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'buffalo_proportion' => 'buffaloProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'buffalo_proportion' => 'setBuffaloProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'buffalo_proportion' => 'getBuffaloProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('buffalo_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['buffalo_proportion'] === null) { + $invalidProperties[] = "'buffalo_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets buffalo_proportion + * + * @return float[] + */ + public function getBuffaloProportion() + { + return $this->container['buffalo_proportion']; + } + + /** + * Sets buffalo_proportion + * + * @param float[] $buffalo_proportion The proportion of the sequestration that is allocated to Buffalo + * + * @return self + */ + public function setBuffaloProportion($buffalo_proportion) + { + if (is_null($buffalo_proportion)) { + throw new \InvalidArgumentException('non-nullable buffalo_proportion cannot be null'); + } + $this->container['buffalo_proportion'] = $buffalo_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200Response.php b/examples/php-api-client/api-client/lib/Model/PostCotton200Response.php new file mode 100644 index 00000000..d04ce110 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200Response.php @@ -0,0 +1,636 @@ + + */ +class PostCotton200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostCotton200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostCotton200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities[] $intensities Emissions intensity for each crop (in order) + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInner.php new file mode 100644 index 00000000..d91368a7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostCotton200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'intensities' => '\OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'intensities' => null, + 'net' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'intensities' => false, + 'net' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'intensities' => 'intensities', + 'net' => 'net', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'intensities' => 'setIntensities', + 'net' => 'setNet', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'intensities' => 'getIntensities', + 'net' => 'getNet', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..2e98741b --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,895 @@ + + */ +class PostCotton200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cotton_yield_produced_tonnes' => 'float', + 'bales_produced' => 'float', + 'lint_produced_tonnes' => 'float', + 'seed_produced_tonnes' => 'float', + 'tonnes_crop_excluding_sequestration' => 'float', + 'tonnes_crop_including_sequestration' => 'float', + 'bales_excluding_sequestration' => 'float', + 'bales_including_sequestration' => 'float', + 'lint_including_sequestration' => 'float', + 'lint_excluding_sequestration' => 'float', + 'seed_including_sequestration' => 'float', + 'seed_excluding_sequestration' => 'float', + 'lint_economic_allocation' => 'float', + 'seed_economic_allocation' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cotton_yield_produced_tonnes' => null, + 'bales_produced' => null, + 'lint_produced_tonnes' => null, + 'seed_produced_tonnes' => null, + 'tonnes_crop_excluding_sequestration' => null, + 'tonnes_crop_including_sequestration' => null, + 'bales_excluding_sequestration' => null, + 'bales_including_sequestration' => null, + 'lint_including_sequestration' => null, + 'lint_excluding_sequestration' => null, + 'seed_including_sequestration' => null, + 'seed_excluding_sequestration' => null, + 'lint_economic_allocation' => null, + 'seed_economic_allocation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'cotton_yield_produced_tonnes' => false, + 'bales_produced' => false, + 'lint_produced_tonnes' => false, + 'seed_produced_tonnes' => false, + 'tonnes_crop_excluding_sequestration' => false, + 'tonnes_crop_including_sequestration' => false, + 'bales_excluding_sequestration' => false, + 'bales_including_sequestration' => false, + 'lint_including_sequestration' => false, + 'lint_excluding_sequestration' => false, + 'seed_including_sequestration' => false, + 'seed_excluding_sequestration' => false, + 'lint_economic_allocation' => false, + 'seed_economic_allocation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cotton_yield_produced_tonnes' => 'cottonYieldProducedTonnes', + 'bales_produced' => 'balesProduced', + 'lint_produced_tonnes' => 'lintProducedTonnes', + 'seed_produced_tonnes' => 'seedProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'tonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'tonnesCropIncludingSequestration', + 'bales_excluding_sequestration' => 'balesExcludingSequestration', + 'bales_including_sequestration' => 'balesIncludingSequestration', + 'lint_including_sequestration' => 'lintIncludingSequestration', + 'lint_excluding_sequestration' => 'lintExcludingSequestration', + 'seed_including_sequestration' => 'seedIncludingSequestration', + 'seed_excluding_sequestration' => 'seedExcludingSequestration', + 'lint_economic_allocation' => 'lintEconomicAllocation', + 'seed_economic_allocation' => 'seedEconomicAllocation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cotton_yield_produced_tonnes' => 'setCottonYieldProducedTonnes', + 'bales_produced' => 'setBalesProduced', + 'lint_produced_tonnes' => 'setLintProducedTonnes', + 'seed_produced_tonnes' => 'setSeedProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'setTonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'setTonnesCropIncludingSequestration', + 'bales_excluding_sequestration' => 'setBalesExcludingSequestration', + 'bales_including_sequestration' => 'setBalesIncludingSequestration', + 'lint_including_sequestration' => 'setLintIncludingSequestration', + 'lint_excluding_sequestration' => 'setLintExcludingSequestration', + 'seed_including_sequestration' => 'setSeedIncludingSequestration', + 'seed_excluding_sequestration' => 'setSeedExcludingSequestration', + 'lint_economic_allocation' => 'setLintEconomicAllocation', + 'seed_economic_allocation' => 'setSeedEconomicAllocation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cotton_yield_produced_tonnes' => 'getCottonYieldProducedTonnes', + 'bales_produced' => 'getBalesProduced', + 'lint_produced_tonnes' => 'getLintProducedTonnes', + 'seed_produced_tonnes' => 'getSeedProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'getTonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'getTonnesCropIncludingSequestration', + 'bales_excluding_sequestration' => 'getBalesExcludingSequestration', + 'bales_including_sequestration' => 'getBalesIncludingSequestration', + 'lint_including_sequestration' => 'getLintIncludingSequestration', + 'lint_excluding_sequestration' => 'getLintExcludingSequestration', + 'seed_including_sequestration' => 'getSeedIncludingSequestration', + 'seed_excluding_sequestration' => 'getSeedExcludingSequestration', + 'lint_economic_allocation' => 'getLintEconomicAllocation', + 'seed_economic_allocation' => 'getSeedEconomicAllocation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('cotton_yield_produced_tonnes', $data ?? [], null); + $this->setIfExists('bales_produced', $data ?? [], null); + $this->setIfExists('lint_produced_tonnes', $data ?? [], null); + $this->setIfExists('seed_produced_tonnes', $data ?? [], null); + $this->setIfExists('tonnes_crop_excluding_sequestration', $data ?? [], null); + $this->setIfExists('tonnes_crop_including_sequestration', $data ?? [], null); + $this->setIfExists('bales_excluding_sequestration', $data ?? [], null); + $this->setIfExists('bales_including_sequestration', $data ?? [], null); + $this->setIfExists('lint_including_sequestration', $data ?? [], null); + $this->setIfExists('lint_excluding_sequestration', $data ?? [], null); + $this->setIfExists('seed_including_sequestration', $data ?? [], null); + $this->setIfExists('seed_excluding_sequestration', $data ?? [], null); + $this->setIfExists('lint_economic_allocation', $data ?? [], null); + $this->setIfExists('seed_economic_allocation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['cotton_yield_produced_tonnes'] === null) { + $invalidProperties[] = "'cotton_yield_produced_tonnes' can't be null"; + } + if ($this->container['bales_produced'] === null) { + $invalidProperties[] = "'bales_produced' can't be null"; + } + if ($this->container['lint_produced_tonnes'] === null) { + $invalidProperties[] = "'lint_produced_tonnes' can't be null"; + } + if ($this->container['seed_produced_tonnes'] === null) { + $invalidProperties[] = "'seed_produced_tonnes' can't be null"; + } + if ($this->container['tonnes_crop_excluding_sequestration'] === null) { + $invalidProperties[] = "'tonnes_crop_excluding_sequestration' can't be null"; + } + if ($this->container['tonnes_crop_including_sequestration'] === null) { + $invalidProperties[] = "'tonnes_crop_including_sequestration' can't be null"; + } + if ($this->container['bales_excluding_sequestration'] === null) { + $invalidProperties[] = "'bales_excluding_sequestration' can't be null"; + } + if ($this->container['bales_including_sequestration'] === null) { + $invalidProperties[] = "'bales_including_sequestration' can't be null"; + } + if ($this->container['lint_including_sequestration'] === null) { + $invalidProperties[] = "'lint_including_sequestration' can't be null"; + } + if ($this->container['lint_excluding_sequestration'] === null) { + $invalidProperties[] = "'lint_excluding_sequestration' can't be null"; + } + if ($this->container['seed_including_sequestration'] === null) { + $invalidProperties[] = "'seed_including_sequestration' can't be null"; + } + if ($this->container['seed_excluding_sequestration'] === null) { + $invalidProperties[] = "'seed_excluding_sequestration' can't be null"; + } + if ($this->container['lint_economic_allocation'] === null) { + $invalidProperties[] = "'lint_economic_allocation' can't be null"; + } + if ($this->container['seed_economic_allocation'] === null) { + $invalidProperties[] = "'seed_economic_allocation' 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 cotton_yield_produced_tonnes + * + * @return float + */ + public function getCottonYieldProducedTonnes() + { + return $this->container['cotton_yield_produced_tonnes']; + } + + /** + * Sets cotton_yield_produced_tonnes + * + * @param float $cotton_yield_produced_tonnes Cotton yield produced in tonnes + * + * @return self + */ + public function setCottonYieldProducedTonnes($cotton_yield_produced_tonnes) + { + if (is_null($cotton_yield_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable cotton_yield_produced_tonnes cannot be null'); + } + $this->container['cotton_yield_produced_tonnes'] = $cotton_yield_produced_tonnes; + + return $this; + } + + /** + * Gets bales_produced + * + * @return float + */ + public function getBalesProduced() + { + return $this->container['bales_produced']; + } + + /** + * Sets bales_produced + * + * @param float $bales_produced Number of bales produced + * + * @return self + */ + public function setBalesProduced($bales_produced) + { + if (is_null($bales_produced)) { + throw new \InvalidArgumentException('non-nullable bales_produced cannot be null'); + } + $this->container['bales_produced'] = $bales_produced; + + return $this; + } + + /** + * Gets lint_produced_tonnes + * + * @return float + */ + public function getLintProducedTonnes() + { + return $this->container['lint_produced_tonnes']; + } + + /** + * Sets lint_produced_tonnes + * + * @param float $lint_produced_tonnes Cotton lint produced in tonnes + * + * @return self + */ + public function setLintProducedTonnes($lint_produced_tonnes) + { + if (is_null($lint_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable lint_produced_tonnes cannot be null'); + } + $this->container['lint_produced_tonnes'] = $lint_produced_tonnes; + + return $this; + } + + /** + * Gets seed_produced_tonnes + * + * @return float + */ + public function getSeedProducedTonnes() + { + return $this->container['seed_produced_tonnes']; + } + + /** + * Sets seed_produced_tonnes + * + * @param float $seed_produced_tonnes Cotton seed produced in tonnes + * + * @return self + */ + public function setSeedProducedTonnes($seed_produced_tonnes) + { + if (is_null($seed_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable seed_produced_tonnes cannot be null'); + } + $this->container['seed_produced_tonnes'] = $seed_produced_tonnes; + + return $this; + } + + /** + * Gets tonnes_crop_excluding_sequestration + * + * @return float + */ + public function getTonnesCropExcludingSequestration() + { + return $this->container['tonnes_crop_excluding_sequestration']; + } + + /** + * Sets tonnes_crop_excluding_sequestration + * + * @param float $tonnes_crop_excluding_sequestration Emissions intensity excluding sequestration, in t-CO2e/t crop + * + * @return self + */ + public function setTonnesCropExcludingSequestration($tonnes_crop_excluding_sequestration) + { + if (is_null($tonnes_crop_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable tonnes_crop_excluding_sequestration cannot be null'); + } + $this->container['tonnes_crop_excluding_sequestration'] = $tonnes_crop_excluding_sequestration; + + return $this; + } + + /** + * Gets tonnes_crop_including_sequestration + * + * @return float + */ + public function getTonnesCropIncludingSequestration() + { + return $this->container['tonnes_crop_including_sequestration']; + } + + /** + * Sets tonnes_crop_including_sequestration + * + * @param float $tonnes_crop_including_sequestration Emissions intensity including sequestration, in t-CO2e/t crop + * + * @return self + */ + public function setTonnesCropIncludingSequestration($tonnes_crop_including_sequestration) + { + if (is_null($tonnes_crop_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable tonnes_crop_including_sequestration cannot be null'); + } + $this->container['tonnes_crop_including_sequestration'] = $tonnes_crop_including_sequestration; + + return $this; + } + + /** + * Gets bales_excluding_sequestration + * + * @return float + */ + public function getBalesExcludingSequestration() + { + return $this->container['bales_excluding_sequestration']; + } + + /** + * Sets bales_excluding_sequestration + * + * @param float $bales_excluding_sequestration Emissions intensity excluding sequestration, in t-CO2e/bale + * + * @return self + */ + public function setBalesExcludingSequestration($bales_excluding_sequestration) + { + if (is_null($bales_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable bales_excluding_sequestration cannot be null'); + } + $this->container['bales_excluding_sequestration'] = $bales_excluding_sequestration; + + return $this; + } + + /** + * Gets bales_including_sequestration + * + * @return float + */ + public function getBalesIncludingSequestration() + { + return $this->container['bales_including_sequestration']; + } + + /** + * Sets bales_including_sequestration + * + * @param float $bales_including_sequestration Emissions intensity including sequestration, in t-CO2e/bale + * + * @return self + */ + public function setBalesIncludingSequestration($bales_including_sequestration) + { + if (is_null($bales_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable bales_including_sequestration cannot be null'); + } + $this->container['bales_including_sequestration'] = $bales_including_sequestration; + + return $this; + } + + /** + * Gets lint_including_sequestration + * + * @return float + */ + public function getLintIncludingSequestration() + { + return $this->container['lint_including_sequestration']; + } + + /** + * Sets lint_including_sequestration + * + * @param float $lint_including_sequestration Emissions intensity of lint including sequestration, in t-CO2e/kg + * + * @return self + */ + public function setLintIncludingSequestration($lint_including_sequestration) + { + if (is_null($lint_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable lint_including_sequestration cannot be null'); + } + $this->container['lint_including_sequestration'] = $lint_including_sequestration; + + return $this; + } + + /** + * Gets lint_excluding_sequestration + * + * @return float + */ + public function getLintExcludingSequestration() + { + return $this->container['lint_excluding_sequestration']; + } + + /** + * Sets lint_excluding_sequestration + * + * @param float $lint_excluding_sequestration Emissions intensity of lint excluding sequestration, in t-CO2e/kg + * + * @return self + */ + public function setLintExcludingSequestration($lint_excluding_sequestration) + { + if (is_null($lint_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable lint_excluding_sequestration cannot be null'); + } + $this->container['lint_excluding_sequestration'] = $lint_excluding_sequestration; + + return $this; + } + + /** + * Gets seed_including_sequestration + * + * @return float + */ + public function getSeedIncludingSequestration() + { + return $this->container['seed_including_sequestration']; + } + + /** + * Sets seed_including_sequestration + * + * @param float $seed_including_sequestration Emissions intensity of seed including sequestration, in t-CO2e/kg + * + * @return self + */ + public function setSeedIncludingSequestration($seed_including_sequestration) + { + if (is_null($seed_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable seed_including_sequestration cannot be null'); + } + $this->container['seed_including_sequestration'] = $seed_including_sequestration; + + return $this; + } + + /** + * Gets seed_excluding_sequestration + * + * @return float + */ + public function getSeedExcludingSequestration() + { + return $this->container['seed_excluding_sequestration']; + } + + /** + * Sets seed_excluding_sequestration + * + * @param float $seed_excluding_sequestration Emissions intensity of seed excluding sequestration, in t-CO2e/kg + * + * @return self + */ + public function setSeedExcludingSequestration($seed_excluding_sequestration) + { + if (is_null($seed_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable seed_excluding_sequestration cannot be null'); + } + $this->container['seed_excluding_sequestration'] = $seed_excluding_sequestration; + + return $this; + } + + /** + * Gets lint_economic_allocation + * + * @return float + */ + public function getLintEconomicAllocation() + { + return $this->container['lint_economic_allocation']; + } + + /** + * Sets lint_economic_allocation + * + * @param float $lint_economic_allocation Emissions intensity of lint using economic allocation, in t-CO2e/kg + * + * @return self + */ + public function setLintEconomicAllocation($lint_economic_allocation) + { + if (is_null($lint_economic_allocation)) { + throw new \InvalidArgumentException('non-nullable lint_economic_allocation cannot be null'); + } + $this->container['lint_economic_allocation'] = $lint_economic_allocation; + + return $this; + } + + /** + * Gets seed_economic_allocation + * + * @return float + */ + public function getSeedEconomicAllocation() + { + return $this->container['seed_economic_allocation']; + } + + /** + * Sets seed_economic_allocation + * + * @param float $seed_economic_allocation Emissions intensity of seed using economic allocation, in t-CO2e/kg + * + * @return self + */ + public function setSeedEconomicAllocation($seed_economic_allocation) + { + if (is_null($seed_economic_allocation)) { + throw new \InvalidArgumentException('non-nullable seed_economic_allocation cannot be null'); + } + $this->container['seed_economic_allocation'] = $seed_economic_allocation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseNet.php new file mode 100644 index 00000000..8a27cb2d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseNet.php @@ -0,0 +1,451 @@ + + */ +class PostCotton200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'crops' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'crops' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'crops' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'crops' => 'crops' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'crops' => 'setCrops' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'crops' => 'getCrops' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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 crops + * + * @return float[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param float[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope1.php new file mode 100644 index 00000000..cc7d1dc3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope1.php @@ -0,0 +1,932 @@ + + */ +class PostCotton200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'fertiliser_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'crop_residue_n2_o' => 'float', + 'field_burning_n2_o' => 'float', + 'field_burning_ch4' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'fertiliser_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'crop_residue_n2_o' => null, + 'field_burning_n2_o' => null, + 'field_burning_ch4' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'fertiliser_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'crop_residue_n2_o' => false, + 'field_burning_n2_o' => false, + 'field_burning_ch4' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'crop_residue_n2_o' => 'cropResidueN2O', + 'field_burning_n2_o' => 'fieldBurningN2O', + 'field_burning_ch4' => 'fieldBurningCH4', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'crop_residue_n2_o' => 'setCropResidueN2O', + 'field_burning_n2_o' => 'setFieldBurningN2O', + 'field_burning_ch4' => 'setFieldBurningCh4', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'crop_residue_n2_o' => 'getCropResidueN2O', + 'field_burning_n2_o' => 'getFieldBurningN2O', + 'field_burning_ch4' => 'getFieldBurningCh4', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('crop_residue_n2_o', $data ?? [], null); + $this->setIfExists('field_burning_n2_o', $data ?? [], null); + $this->setIfExists('field_burning_ch4', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['crop_residue_n2_o'] === null) { + $invalidProperties[] = "'crop_residue_n2_o' can't be null"; + } + if ($this->container['field_burning_n2_o'] === null) { + $invalidProperties[] = "'field_burning_n2_o' can't be null"; + } + if ($this->container['field_burning_ch4'] === null) { + $invalidProperties[] = "'field_burning_ch4' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets crop_residue_n2_o + * + * @return float + */ + public function getCropResidueN2O() + { + return $this->container['crop_residue_n2_o']; + } + + /** + * Sets crop_residue_n2_o + * + * @param float $crop_residue_n2_o N2O emissions from crop residue, in tonnes-CO2e + * + * @return self + */ + public function setCropResidueN2O($crop_residue_n2_o) + { + if (is_null($crop_residue_n2_o)) { + throw new \InvalidArgumentException('non-nullable crop_residue_n2_o cannot be null'); + } + $this->container['crop_residue_n2_o'] = $crop_residue_n2_o; + + return $this; + } + + /** + * Gets field_burning_n2_o + * + * @return float + */ + public function getFieldBurningN2O() + { + return $this->container['field_burning_n2_o']; + } + + /** + * Sets field_burning_n2_o + * + * @param float $field_burning_n2_o N2O emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningN2O($field_burning_n2_o) + { + if (is_null($field_burning_n2_o)) { + throw new \InvalidArgumentException('non-nullable field_burning_n2_o cannot be null'); + } + $this->container['field_burning_n2_o'] = $field_burning_n2_o; + + return $this; + } + + /** + * Gets field_burning_ch4 + * + * @return float + */ + public function getFieldBurningCh4() + { + return $this->container['field_burning_ch4']; + } + + /** + * Sets field_burning_ch4 + * + * @param float $field_burning_ch4 CH4 emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningCh4($field_burning_ch4) + { + if (is_null($field_burning_ch4)) { + throw new \InvalidArgumentException('non-nullable field_burning_ch4 cannot be null'); + } + $this->container['field_burning_ch4'] = $field_burning_ch4; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope3.php new file mode 100644 index 00000000..5e7f938c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCotton200ResponseScope3.php @@ -0,0 +1,599 @@ + + */ +class PostCotton200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => 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 = [ + 'fertiliser' => 'fertiliser', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCottonRequest.php b/examples/php-api-client/api-client/lib/Model/PostCottonRequest.php new file mode 100644 index 00000000..73ada377 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCottonRequest.php @@ -0,0 +1,626 @@ + + */ +class PostCottonRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'crops' => '\OpenAPI\Client\Model\PostCottonRequestCropsInner[]', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'vegetation' => '\OpenAPI\Client\Model\PostCottonRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'crops' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'crops' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'crops' => 'crops', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'crops' => 'setCrops', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'crops' => 'getCrops', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets crops + * + * @return \OpenAPI\Client\Model\PostCottonRequestCropsInner[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param \OpenAPI\Client\Model\PostCottonRequestCropsInner[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostCottonRequest., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostCottonRequest., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCottonRequestCropsInner.php b/examples/php-api-client/api-client/lib/Model/PostCottonRequestCropsInner.php new file mode 100644 index 00000000..76e6816e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCottonRequestCropsInner.php @@ -0,0 +1,1479 @@ + + */ +class PostCottonRequestCropsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_request_crops_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'average_cotton_yield' => 'float', + 'area_sown' => 'float', + 'average_weight_per_bale_kg' => 'float', + 'cotton_lint_per_bale_kg' => 'float', + 'cotton_seed_per_bale_kg' => 'float', + 'waste_per_bale_kg' => 'float', + 'urea_application' => 'float', + 'other_fertiliser_type' => 'string', + 'other_fertiliser_application' => 'float', + 'non_urea_nitrogen' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'single_super_phosphate' => 'float', + 'rainfall_above600' => 'bool', + 'fraction_of_annual_crop_burnt' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_allocation' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'diesel_use' => 'float', + 'petrol_use' => 'float', + 'lpg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'average_cotton_yield' => null, + 'area_sown' => null, + 'average_weight_per_bale_kg' => null, + 'cotton_lint_per_bale_kg' => null, + 'cotton_seed_per_bale_kg' => null, + 'waste_per_bale_kg' => null, + 'urea_application' => null, + 'other_fertiliser_type' => null, + 'other_fertiliser_application' => null, + 'non_urea_nitrogen' => null, + 'urea_ammonium_nitrate' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'single_super_phosphate' => null, + 'rainfall_above600' => null, + 'fraction_of_annual_crop_burnt' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_allocation' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'diesel_use' => null, + 'petrol_use' => null, + 'lpg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'average_cotton_yield' => false, + 'area_sown' => false, + 'average_weight_per_bale_kg' => false, + 'cotton_lint_per_bale_kg' => false, + 'cotton_seed_per_bale_kg' => false, + 'waste_per_bale_kg' => false, + 'urea_application' => false, + 'other_fertiliser_type' => false, + 'other_fertiliser_application' => false, + 'non_urea_nitrogen' => false, + 'urea_ammonium_nitrate' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'single_super_phosphate' => false, + 'rainfall_above600' => false, + 'fraction_of_annual_crop_burnt' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_allocation' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'diesel_use' => false, + 'petrol_use' => false, + 'lpg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'average_cotton_yield' => 'averageCottonYield', + 'area_sown' => 'areaSown', + 'average_weight_per_bale_kg' => 'averageWeightPerBaleKg', + 'cotton_lint_per_bale_kg' => 'cottonLintPerBaleKg', + 'cotton_seed_per_bale_kg' => 'cottonSeedPerBaleKg', + 'waste_per_bale_kg' => 'wastePerBaleKg', + 'urea_application' => 'ureaApplication', + 'other_fertiliser_type' => 'otherFertiliserType', + 'other_fertiliser_application' => 'otherFertiliserApplication', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'single_super_phosphate' => 'singleSuperPhosphate', + 'rainfall_above600' => 'rainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'fractionOfAnnualCropBurnt', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_allocation' => 'electricityAllocation', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'diesel_use' => 'dieselUse', + 'petrol_use' => 'petrolUse', + 'lpg' => 'lpg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'average_cotton_yield' => 'setAverageCottonYield', + 'area_sown' => 'setAreaSown', + 'average_weight_per_bale_kg' => 'setAverageWeightPerBaleKg', + 'cotton_lint_per_bale_kg' => 'setCottonLintPerBaleKg', + 'cotton_seed_per_bale_kg' => 'setCottonSeedPerBaleKg', + 'waste_per_bale_kg' => 'setWastePerBaleKg', + 'urea_application' => 'setUreaApplication', + 'other_fertiliser_type' => 'setOtherFertiliserType', + 'other_fertiliser_application' => 'setOtherFertiliserApplication', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'single_super_phosphate' => 'setSingleSuperPhosphate', + 'rainfall_above600' => 'setRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'setFractionOfAnnualCropBurnt', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'setElectricityAllocation', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'diesel_use' => 'setDieselUse', + 'petrol_use' => 'setPetrolUse', + 'lpg' => 'setLpg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'average_cotton_yield' => 'getAverageCottonYield', + 'area_sown' => 'getAreaSown', + 'average_weight_per_bale_kg' => 'getAverageWeightPerBaleKg', + 'cotton_lint_per_bale_kg' => 'getCottonLintPerBaleKg', + 'cotton_seed_per_bale_kg' => 'getCottonSeedPerBaleKg', + 'waste_per_bale_kg' => 'getWastePerBaleKg', + 'urea_application' => 'getUreaApplication', + 'other_fertiliser_type' => 'getOtherFertiliserType', + 'other_fertiliser_application' => 'getOtherFertiliserApplication', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'single_super_phosphate' => 'getSingleSuperPhosphate', + 'rainfall_above600' => 'getRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'getFractionOfAnnualCropBurnt', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'getElectricityAllocation', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'diesel_use' => 'getDieselUse', + 'petrol_use' => 'getPetrolUse', + 'lpg' => 'getLpg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const OTHER_FERTILISER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP = 'Monoammonium phosphate (MAP)'; + public const OTHER_FERTILISER_TYPE_DIAMMONIUM_PHOSPHATE__DAP = 'Diammonium Phosphate (DAP)'; + public const OTHER_FERTILISER_TYPE_UREA_AMMONIUM_NITRATE__UAN = 'Urea-Ammonium Nitrate (UAN)'; + public const OTHER_FERTILISER_TYPE_AMMONIUM_NITRATE__AN = 'Ammonium Nitrate (AN)'; + public const OTHER_FERTILISER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN = 'Calcium Ammonium Nitrate (CAN)'; + public const OTHER_FERTILISER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP = 'Triple Superphosphate (TSP)'; + public const OTHER_FERTILISER_TYPE_SUPER_POTASH_1_1 = 'Super Potash 1:1'; + public const OTHER_FERTILISER_TYPE_SUPER_POTASH_2_1 = 'Super Potash 2:1'; + public const OTHER_FERTILISER_TYPE_SUPER_POTASH_3_1 = 'Super Potash 3:1'; + public const OTHER_FERTILISER_TYPE_SUPER_POTASH_4_1 = 'Super Potash 4:1'; + public const OTHER_FERTILISER_TYPE_SUPER_POTASH_5_1 = 'Super Potash 5:1'; + public const OTHER_FERTILISER_TYPE_MURIATE_OF_POTASH = 'Muriate of Potash'; + public const OTHER_FERTILISER_TYPE_SULPHATE_OF_POTASH = 'Sulphate of Potash'; + public const OTHER_FERTILISER_TYPE_SULPHATE_OF_AMMONIA = 'Sulphate of Ammonia'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getOtherFertiliserTypeAllowableValues() + { + return [ + self::OTHER_FERTILISER_TYPE_MONOAMMONIUM_PHOSPHATE__MAP, + self::OTHER_FERTILISER_TYPE_DIAMMONIUM_PHOSPHATE__DAP, + self::OTHER_FERTILISER_TYPE_UREA_AMMONIUM_NITRATE__UAN, + self::OTHER_FERTILISER_TYPE_AMMONIUM_NITRATE__AN, + self::OTHER_FERTILISER_TYPE_CALCIUM_AMMONIUM_NITRATE__CAN, + self::OTHER_FERTILISER_TYPE_TRIPLE_SUPERPHOSPHATE__TSP, + self::OTHER_FERTILISER_TYPE_SUPER_POTASH_1_1, + self::OTHER_FERTILISER_TYPE_SUPER_POTASH_2_1, + self::OTHER_FERTILISER_TYPE_SUPER_POTASH_3_1, + self::OTHER_FERTILISER_TYPE_SUPER_POTASH_4_1, + self::OTHER_FERTILISER_TYPE_SUPER_POTASH_5_1, + self::OTHER_FERTILISER_TYPE_MURIATE_OF_POTASH, + self::OTHER_FERTILISER_TYPE_SULPHATE_OF_POTASH, + self::OTHER_FERTILISER_TYPE_SULPHATE_OF_AMMONIA, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('average_cotton_yield', $data ?? [], null); + $this->setIfExists('area_sown', $data ?? [], null); + $this->setIfExists('average_weight_per_bale_kg', $data ?? [], null); + $this->setIfExists('cotton_lint_per_bale_kg', $data ?? [], null); + $this->setIfExists('cotton_seed_per_bale_kg', $data ?? [], null); + $this->setIfExists('waste_per_bale_kg', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('other_fertiliser_type', $data ?? [], null); + $this->setIfExists('other_fertiliser_application', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], 0); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], 0); + $this->setIfExists('phosphorus_application', $data ?? [], 0); + $this->setIfExists('potassium_application', $data ?? [], 0); + $this->setIfExists('sulfur_application', $data ?? [], 0); + $this->setIfExists('single_super_phosphate', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('fraction_of_annual_crop_burnt', $data ?? [], 0); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_allocation', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('diesel_use', $data ?? [], null); + $this->setIfExists('petrol_use', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_cotton_yield'] === null) { + $invalidProperties[] = "'average_cotton_yield' can't be null"; + } + if ($this->container['area_sown'] === null) { + $invalidProperties[] = "'area_sown' can't be null"; + } + if ($this->container['average_weight_per_bale_kg'] === null) { + $invalidProperties[] = "'average_weight_per_bale_kg' can't be null"; + } + if ($this->container['cotton_lint_per_bale_kg'] === null) { + $invalidProperties[] = "'cotton_lint_per_bale_kg' can't be null"; + } + if ($this->container['cotton_seed_per_bale_kg'] === null) { + $invalidProperties[] = "'cotton_seed_per_bale_kg' can't be null"; + } + if ($this->container['waste_per_bale_kg'] === null) { + $invalidProperties[] = "'waste_per_bale_kg' can't be null"; + } + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + $allowedValues = $this->getOtherFertiliserTypeAllowableValues(); + if (!is_null($this->container['other_fertiliser_type']) && !in_array($this->container['other_fertiliser_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'other_fertiliser_type', must be one of '%s'", + $this->container['other_fertiliser_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['other_fertiliser_application'] === null) { + $invalidProperties[] = "'other_fertiliser_application' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['single_super_phosphate'] === null) { + $invalidProperties[] = "'single_super_phosphate' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['fraction_of_annual_crop_burnt'] === null) { + $invalidProperties[] = "'fraction_of_annual_crop_burnt' can't be null"; + } + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_allocation'] === null) { + $invalidProperties[] = "'electricity_allocation' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['diesel_use'] === null) { + $invalidProperties[] = "'diesel_use' can't be null"; + } + if ($this->container['petrol_use'] === null) { + $invalidProperties[] = "'petrol_use' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets average_cotton_yield + * + * @return float + */ + public function getAverageCottonYield() + { + return $this->container['average_cotton_yield']; + } + + /** + * Sets average_cotton_yield + * + * @param float $average_cotton_yield Average cotton yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageCottonYield($average_cotton_yield) + { + if (is_null($average_cotton_yield)) { + throw new \InvalidArgumentException('non-nullable average_cotton_yield cannot be null'); + } + $this->container['average_cotton_yield'] = $average_cotton_yield; + + return $this; + } + + /** + * Gets area_sown + * + * @return float + */ + public function getAreaSown() + { + return $this->container['area_sown']; + } + + /** + * Sets area_sown + * + * @param float $area_sown Area sown, in ha (hectares) + * + * @return self + */ + public function setAreaSown($area_sown) + { + if (is_null($area_sown)) { + throw new \InvalidArgumentException('non-nullable area_sown cannot be null'); + } + $this->container['area_sown'] = $area_sown; + + return $this; + } + + /** + * Gets average_weight_per_bale_kg + * + * @return float + */ + public function getAverageWeightPerBaleKg() + { + return $this->container['average_weight_per_bale_kg']; + } + + /** + * Sets average_weight_per_bale_kg + * + * @param float $average_weight_per_bale_kg Average weight of unprocessed cotton per bale, in kg + * + * @return self + */ + public function setAverageWeightPerBaleKg($average_weight_per_bale_kg) + { + if (is_null($average_weight_per_bale_kg)) { + throw new \InvalidArgumentException('non-nullable average_weight_per_bale_kg cannot be null'); + } + $this->container['average_weight_per_bale_kg'] = $average_weight_per_bale_kg; + + return $this; + } + + /** + * Gets cotton_lint_per_bale_kg + * + * @return float + */ + public function getCottonLintPerBaleKg() + { + return $this->container['cotton_lint_per_bale_kg']; + } + + /** + * Sets cotton_lint_per_bale_kg + * + * @param float $cotton_lint_per_bale_kg Average weight of cotton lint per bale, in kg + * + * @return self + */ + public function setCottonLintPerBaleKg($cotton_lint_per_bale_kg) + { + if (is_null($cotton_lint_per_bale_kg)) { + throw new \InvalidArgumentException('non-nullable cotton_lint_per_bale_kg cannot be null'); + } + $this->container['cotton_lint_per_bale_kg'] = $cotton_lint_per_bale_kg; + + return $this; + } + + /** + * Gets cotton_seed_per_bale_kg + * + * @return float + */ + public function getCottonSeedPerBaleKg() + { + return $this->container['cotton_seed_per_bale_kg']; + } + + /** + * Sets cotton_seed_per_bale_kg + * + * @param float $cotton_seed_per_bale_kg Average weight of cotton seed produced per bale, in kg + * + * @return self + */ + public function setCottonSeedPerBaleKg($cotton_seed_per_bale_kg) + { + if (is_null($cotton_seed_per_bale_kg)) { + throw new \InvalidArgumentException('non-nullable cotton_seed_per_bale_kg cannot be null'); + } + $this->container['cotton_seed_per_bale_kg'] = $cotton_seed_per_bale_kg; + + return $this; + } + + /** + * Gets waste_per_bale_kg + * + * @return float + */ + public function getWastePerBaleKg() + { + return $this->container['waste_per_bale_kg']; + } + + /** + * Sets waste_per_bale_kg + * + * @param float $waste_per_bale_kg Average weight of cotton waste produced per bale, in kg + * + * @return self + */ + public function setWastePerBaleKg($waste_per_bale_kg) + { + if (is_null($waste_per_bale_kg)) { + throw new \InvalidArgumentException('non-nullable waste_per_bale_kg cannot be null'); + } + $this->container['waste_per_bale_kg'] = $waste_per_bale_kg; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets other_fertiliser_type + * + * @return string|null + * @deprecated + */ + public function getOtherFertiliserType() + { + return $this->container['other_fertiliser_type']; + } + + /** + * Sets other_fertiliser_type + * + * @param string|null $other_fertiliser_type Other N fertiliser type + * + * @return self + * @deprecated + */ + public function setOtherFertiliserType($other_fertiliser_type) + { + if (is_null($other_fertiliser_type)) { + throw new \InvalidArgumentException('non-nullable other_fertiliser_type cannot be null'); + } + $allowedValues = $this->getOtherFertiliserTypeAllowableValues(); + if (!in_array($other_fertiliser_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'other_fertiliser_type', must be one of '%s'", + $other_fertiliser_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['other_fertiliser_type'] = $other_fertiliser_type; + + return $this; + } + + /** + * Gets other_fertiliser_application + * + * @return float + */ + public function getOtherFertiliserApplication() + { + return $this->container['other_fertiliser_application']; + } + + /** + * Sets other_fertiliser_application + * + * @param float $other_fertiliser_application Other N fertiliser application, in kg/ha (kilograms per hectare) + * + * @return self + */ + public function setOtherFertiliserApplication($other_fertiliser_application) + { + if (is_null($other_fertiliser_application)) { + throw new \InvalidArgumentException('non-nullable other_fertiliser_application cannot be null'); + } + $this->container['other_fertiliser_application'] = $other_fertiliser_application; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets single_super_phosphate + * + * @return float + */ + public function getSingleSuperPhosphate() + { + return $this->container['single_super_phosphate']; + } + + /** + * Sets single_super_phosphate + * + * @param float $single_super_phosphate Single superphosphate use, in kg/ha (kilograms per hectare) + * + * @return self + */ + public function setSingleSuperPhosphate($single_super_phosphate) + { + if (is_null($single_super_phosphate)) { + throw new \InvalidArgumentException('non-nullable single_super_phosphate cannot be null'); + } + $this->container['single_super_phosphate'] = $single_super_phosphate; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets fraction_of_annual_crop_burnt + * + * @return float + * @deprecated + */ + public function getFractionOfAnnualCropBurnt() + { + return $this->container['fraction_of_annual_crop_burnt']; + } + + /** + * Sets fraction_of_annual_crop_burnt + * + * @param float $fraction_of_annual_crop_burnt Fraction of annual production of crop that is burnt. If included, this should only ever be 0 for cotton + * + * @return self + * @deprecated + */ + public function setFractionOfAnnualCropBurnt($fraction_of_annual_crop_burnt) + { + if (is_null($fraction_of_annual_crop_burnt)) { + throw new \InvalidArgumentException('non-nullable fraction_of_annual_crop_burnt cannot be null'); + } + $this->container['fraction_of_annual_crop_burnt'] = $fraction_of_annual_crop_burnt; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_allocation + * + * @return float + */ + public function getElectricityAllocation() + { + return $this->container['electricity_allocation']; + } + + /** + * Sets electricity_allocation + * + * @param float $electricity_allocation Percentage of electricity use to allocate to this crop, from 0 to 1 + * + * @return self + */ + public function setElectricityAllocation($electricity_allocation) + { + if (is_null($electricity_allocation)) { + throw new \InvalidArgumentException('non-nullable electricity_allocation cannot be null'); + } + $this->container['electricity_allocation'] = $electricity_allocation; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets diesel_use + * + * @return float + */ + public function getDieselUse() + { + return $this->container['diesel_use']; + } + + /** + * Sets diesel_use + * + * @param float $diesel_use Diesel usage in L (litres) + * + * @return self + */ + public function setDieselUse($diesel_use) + { + if (is_null($diesel_use)) { + throw new \InvalidArgumentException('non-nullable diesel_use cannot be null'); + } + $this->container['diesel_use'] = $diesel_use; + + return $this; + } + + /** + * Gets petrol_use + * + * @return float + */ + public function getPetrolUse() + { + return $this->container['petrol_use']; + } + + /** + * Sets petrol_use + * + * @param float $petrol_use Petrol usage in L (litres) + * + * @return self + */ + public function setPetrolUse($petrol_use) + { + if (is_null($petrol_use)) { + throw new \InvalidArgumentException('non-nullable petrol_use cannot be null'); + } + $this->container['petrol_use'] = $petrol_use; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostCottonRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostCottonRequestVegetationInner.php new file mode 100644 index 00000000..52a7e801 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostCottonRequestVegetationInner.php @@ -0,0 +1,450 @@ + + */ +class PostCottonRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_cotton_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'allocation_to_crops' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'allocation_to_crops' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'allocation_to_crops' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'allocation_to_crops' => 'allocationToCrops' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'allocation_to_crops' => 'setAllocationToCrops' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'allocation_to_crops' => 'getAllocationToCrops' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('allocation_to_crops', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['allocation_to_crops'] === null) { + $invalidProperties[] = "'allocation_to_crops' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets allocation_to_crops + * + * @return float[] + */ + public function getAllocationToCrops() + { + return $this->container['allocation_to_crops']; + } + + /** + * Sets allocation_to_crops + * + * @param float[] $allocation_to_crops allocation_to_crops + * + * @return self + */ + public function setAllocationToCrops($allocation_to_crops) + { + if (is_null($allocation_to_crops)) { + throw new \InvalidArgumentException('non-nullable allocation_to_crops cannot be null'); + } + $this->container['allocation_to_crops'] = $allocation_to_crops; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200Response.php b/examples/php-api-client/api-client/lib/Model/PostDairy200Response.php new file mode 100644 index 00000000..a0ae157d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200Response.php @@ -0,0 +1,636 @@ + + */ +class PostDairy200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostDairy200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostDairy200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostDairy200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostDairy200ResponseIntensities', + 'intermediate' => '\OpenAPI\Client\Model\PostDairy200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntensities.php new file mode 100644 index 00000000..b950831f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntensities.php @@ -0,0 +1,450 @@ + + */ +class PostDairy200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'milk_solids_produced_tonnes' => 'float', + 'intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'milk_solids_produced_tonnes' => null, + 'intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'milk_solids_produced_tonnes' => false, + 'intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'milk_solids_produced_tonnes' => 'milkSolidsProducedTonnes', + 'intensity' => 'intensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'milk_solids_produced_tonnes' => 'setMilkSolidsProducedTonnes', + 'intensity' => 'setIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'milk_solids_produced_tonnes' => 'getMilkSolidsProducedTonnes', + 'intensity' => 'getIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('milk_solids_produced_tonnes', $data ?? [], null); + $this->setIfExists('intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['milk_solids_produced_tonnes'] === null) { + $invalidProperties[] = "'milk_solids_produced_tonnes' can't be null"; + } + if ($this->container['intensity'] === null) { + $invalidProperties[] = "'intensity' 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 milk_solids_produced_tonnes + * + * @return float + */ + public function getMilkSolidsProducedTonnes() + { + return $this->container['milk_solids_produced_tonnes']; + } + + /** + * Sets milk_solids_produced_tonnes + * + * @param float $milk_solids_produced_tonnes Milk solids produced in tonnes + * + * @return self + */ + public function setMilkSolidsProducedTonnes($milk_solids_produced_tonnes) + { + if (is_null($milk_solids_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable milk_solids_produced_tonnes cannot be null'); + } + $this->container['milk_solids_produced_tonnes'] = $milk_solids_produced_tonnes; + + return $this; + } + + /** + * Gets intensity + * + * @return float + */ + public function getIntensity() + { + return $this->container['intensity']; + } + + /** + * Sets intensity + * + * @param float $intensity Dairy intensities including carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setIntensity($intensity) + { + if (is_null($intensity)) { + throw new \InvalidArgumentException('non-nullable intensity cannot be null'); + } + $this->container['intensity'] = $intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntermediateInner.php new file mode 100644 index 00000000..b6e7a6d5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostDairy200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostDairy200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostDairy200ResponseScope3', + 'net' => '\OpenAPI\Client\Model\PostDairy200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostDairy200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostDairy200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostDairy200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseNet.php new file mode 100644 index 00000000..1aa6f091 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseNet.php @@ -0,0 +1,413 @@ + + */ +class PostDairy200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total net emissions of this activity, in tonnes-CO2e/year + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope1.php new file mode 100644 index 00000000..83971897 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope1.php @@ -0,0 +1,1117 @@ + + */ +class PostDairy200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'enteric_ch4' => 'float', + 'manure_management_ch4' => 'float', + 'manure_management_n2_o' => 'float', + 'animal_waste_n2_o' => 'float', + 'fertiliser_n2_o' => 'float', + 'urine_and_dung_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'transport_n2_o' => 'float', + 'transport_ch4' => 'float', + 'transport_co2' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'enteric_ch4' => null, + 'manure_management_ch4' => null, + 'manure_management_n2_o' => null, + 'animal_waste_n2_o' => null, + 'fertiliser_n2_o' => null, + 'urine_and_dung_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'transport_n2_o' => null, + 'transport_ch4' => null, + 'transport_co2' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'enteric_ch4' => false, + 'manure_management_ch4' => false, + 'manure_management_n2_o' => false, + 'animal_waste_n2_o' => false, + 'fertiliser_n2_o' => false, + 'urine_and_dung_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'transport_n2_o' => false, + 'transport_ch4' => false, + 'transport_co2' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'enteric_ch4' => 'entericCH4', + 'manure_management_ch4' => 'manureManagementCH4', + 'manure_management_n2_o' => 'manureManagementN2O', + 'animal_waste_n2_o' => 'animalWasteN2O', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'urine_and_dung_n2_o' => 'urineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'transport_n2_o' => 'transportN2O', + 'transport_ch4' => 'transportCH4', + 'transport_co2' => 'transportCO2', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'enteric_ch4' => 'setEntericCh4', + 'manure_management_ch4' => 'setManureManagementCh4', + 'manure_management_n2_o' => 'setManureManagementN2O', + 'animal_waste_n2_o' => 'setAnimalWasteN2O', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'urine_and_dung_n2_o' => 'setUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'transport_n2_o' => 'setTransportN2O', + 'transport_ch4' => 'setTransportCh4', + 'transport_co2' => 'setTransportCo2', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'enteric_ch4' => 'getEntericCh4', + 'manure_management_ch4' => 'getManureManagementCh4', + 'manure_management_n2_o' => 'getManureManagementN2O', + 'animal_waste_n2_o' => 'getAnimalWasteN2O', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'urine_and_dung_n2_o' => 'getUrineAndDungN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'transport_n2_o' => 'getTransportN2O', + 'transport_ch4' => 'getTransportCh4', + 'transport_co2' => 'getTransportCo2', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('enteric_ch4', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('manure_management_n2_o', $data ?? [], null); + $this->setIfExists('animal_waste_n2_o', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('urine_and_dung_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('transport_n2_o', $data ?? [], null); + $this->setIfExists('transport_ch4', $data ?? [], null); + $this->setIfExists('transport_co2', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['enteric_ch4'] === null) { + $invalidProperties[] = "'enteric_ch4' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['manure_management_n2_o'] === null) { + $invalidProperties[] = "'manure_management_n2_o' can't be null"; + } + if ($this->container['animal_waste_n2_o'] === null) { + $invalidProperties[] = "'animal_waste_n2_o' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['urine_and_dung_n2_o'] === null) { + $invalidProperties[] = "'urine_and_dung_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['transport_n2_o'] === null) { + $invalidProperties[] = "'transport_n2_o' can't be null"; + } + if ($this->container['transport_ch4'] === null) { + $invalidProperties[] = "'transport_ch4' can't be null"; + } + if ($this->container['transport_co2'] === null) { + $invalidProperties[] = "'transport_co2' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets enteric_ch4 + * + * @return float + */ + public function getEntericCh4() + { + return $this->container['enteric_ch4']; + } + + /** + * Sets enteric_ch4 + * + * @param float $enteric_ch4 CH4 emissions from enteric fermentation, in tonnes-CO2e + * + * @return self + */ + public function setEntericCh4($enteric_ch4) + { + if (is_null($enteric_ch4)) { + throw new \InvalidArgumentException('non-nullable enteric_ch4 cannot be null'); + } + $this->container['enteric_ch4'] = $enteric_ch4; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets manure_management_n2_o + * + * @return float + */ + public function getManureManagementN2O() + { + return $this->container['manure_management_n2_o']; + } + + /** + * Sets manure_management_n2_o + * + * @param float $manure_management_n2_o N2O emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementN2O($manure_management_n2_o) + { + if (is_null($manure_management_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_management_n2_o cannot be null'); + } + $this->container['manure_management_n2_o'] = $manure_management_n2_o; + + return $this; + } + + /** + * Gets animal_waste_n2_o + * + * @return float + */ + public function getAnimalWasteN2O() + { + return $this->container['animal_waste_n2_o']; + } + + /** + * Sets animal_waste_n2_o + * + * @param float $animal_waste_n2_o N2O emissions from animal waste, in tonnes-CO2e + * + * @return self + */ + public function setAnimalWasteN2O($animal_waste_n2_o) + { + if (is_null($animal_waste_n2_o)) { + throw new \InvalidArgumentException('non-nullable animal_waste_n2_o cannot be null'); + } + $this->container['animal_waste_n2_o'] = $animal_waste_n2_o; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets urine_and_dung_n2_o + * + * @return float + */ + public function getUrineAndDungN2O() + { + return $this->container['urine_and_dung_n2_o']; + } + + /** + * Sets urine_and_dung_n2_o + * + * @param float $urine_and_dung_n2_o N2O emissions from urine and dung, in tonnes-CO2e + * + * @return self + */ + public function setUrineAndDungN2O($urine_and_dung_n2_o) + { + if (is_null($urine_and_dung_n2_o)) { + throw new \InvalidArgumentException('non-nullable urine_and_dung_n2_o cannot be null'); + } + $this->container['urine_and_dung_n2_o'] = $urine_and_dung_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets transport_n2_o + * + * @return float + */ + public function getTransportN2O() + { + return $this->container['transport_n2_o']; + } + + /** + * Sets transport_n2_o + * + * @param float $transport_n2_o N2O emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportN2O($transport_n2_o) + { + if (is_null($transport_n2_o)) { + throw new \InvalidArgumentException('non-nullable transport_n2_o cannot be null'); + } + $this->container['transport_n2_o'] = $transport_n2_o; + + return $this; + } + + /** + * Gets transport_ch4 + * + * @return float + */ + public function getTransportCh4() + { + return $this->container['transport_ch4']; + } + + /** + * Sets transport_ch4 + * + * @param float $transport_ch4 CH4 emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportCh4($transport_ch4) + { + if (is_null($transport_ch4)) { + throw new \InvalidArgumentException('non-nullable transport_ch4 cannot be null'); + } + $this->container['transport_ch4'] = $transport_ch4; + + return $this; + } + + /** + * Gets transport_co2 + * + * @return float + */ + public function getTransportCo2() + { + return $this->container['transport_co2']; + } + + /** + * Sets transport_co2 + * + * @param float $transport_co2 CO2 emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportCo2($transport_co2) + { + if (is_null($transport_co2)) { + throw new \InvalidArgumentException('non-nullable transport_co2 cannot be null'); + } + $this->container['transport_co2'] = $transport_co2; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope3.php new file mode 100644 index 00000000..aa0dab90 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairy200ResponseScope3.php @@ -0,0 +1,636 @@ + + */ +class PostDairy200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'purchased_feed' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'purchased_feed' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'purchased_feed' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => 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 = [ + 'fertiliser' => 'fertiliser', + 'purchased_feed' => 'purchasedFeed', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'purchased_feed' => 'setPurchasedFeed', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'purchased_feed' => 'getPurchasedFeed', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('purchased_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['purchased_feed'] === null) { + $invalidProperties[] = "'purchased_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets purchased_feed + * + * @return float + */ + public function getPurchasedFeed() + { + return $this->container['purchased_feed']; + } + + /** + * Sets purchased_feed + * + * @param float $purchased_feed Emissions from purchased feed, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedFeed($purchased_feed) + { + if (is_null($purchased_feed)) { + throw new \InvalidArgumentException('non-nullable purchased_feed cannot be null'); + } + $this->container['purchased_feed'] = $purchased_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequest.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequest.php new file mode 100644 index 00000000..35586502 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequest.php @@ -0,0 +1,648 @@ + + */ +class PostDairyRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'rainfall_above600' => 'bool', + 'production_system' => 'string', + 'dairy' => '\OpenAPI\Client\Model\PostDairyRequestDairyInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostDairyRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'rainfall_above600' => null, + 'production_system' => null, + 'dairy' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'rainfall_above600' => false, + 'production_system' => false, + 'dairy' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'rainfall_above600' => 'rainfallAbove600', + 'production_system' => 'productionSystem', + 'dairy' => 'dairy', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'rainfall_above600' => 'setRainfallAbove600', + 'production_system' => 'setProductionSystem', + 'dairy' => 'setDairy', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'rainfall_above600' => 'getRainfallAbove600', + 'production_system' => 'getProductionSystem', + 'dairy' => 'getDairy', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const PRODUCTION_SYSTEM_NON_IRRIGATED_CROP = 'Non-irrigated Crop'; + public const PRODUCTION_SYSTEM_IRRIGATED_CROP = 'Irrigated Crop'; + public const PRODUCTION_SYSTEM_IRRIGATED_PASTURE = 'Irrigated Pasture'; + public const PRODUCTION_SYSTEM_NON_IRRIGATED_PASTURE = 'Non-irrigated Pasture'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductionSystemAllowableValues() + { + return [ + self::PRODUCTION_SYSTEM_NON_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_IRRIGATED_PASTURE, + self::PRODUCTION_SYSTEM_NON_IRRIGATED_PASTURE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('production_system', $data ?? [], null); + $this->setIfExists('dairy', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['production_system'] === null) { + $invalidProperties[] = "'production_system' can't be null"; + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!is_null($this->container['production_system']) && !in_array($this->container['production_system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'production_system', must be one of '%s'", + $this->container['production_system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['dairy'] === null) { + $invalidProperties[] = "'dairy' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets production_system + * + * @return string + */ + public function getProductionSystem() + { + return $this->container['production_system']; + } + + /** + * Sets production_system + * + * @param string $production_system Production system + * + * @return self + */ + public function setProductionSystem($production_system) + { + if (is_null($production_system)) { + throw new \InvalidArgumentException('non-nullable production_system cannot be null'); + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!in_array($production_system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'production_system', must be one of '%s'", + $production_system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['production_system'] = $production_system; + + return $this; + } + + /** + * Gets dairy + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInner[] + */ + public function getDairy() + { + return $this->container['dairy']; + } + + /** + * Sets dairy + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInner[] $dairy dairy + * + * @return self + */ + public function setDairy($dairy) + { + if (is_null($dairy)) { + throw new \InvalidArgumentException('non-nullable dairy cannot be null'); + } + $this->container['dairy'] = $dairy; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostDairyRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostDairyRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInner.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInner.php new file mode 100644 index 00000000..bc55b30f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInner.php @@ -0,0 +1,1255 @@ + + */ +class PostDairyRequestDairyInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'seasonal_fertiliser' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliser', + 'areas' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerAreas', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'cottonseed_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'manure_management_milking_cows' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows', + 'manure_management_other_dairy_cows' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows', + 'emissions_allocation_to_red_meat_production' => 'float', + 'truck_type' => 'string', + 'distance_cattle_transported' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'seasonal_fertiliser' => null, + 'areas' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'cottonseed_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'manure_management_milking_cows' => null, + 'manure_management_other_dairy_cows' => null, + 'emissions_allocation_to_red_meat_production' => null, + 'truck_type' => null, + 'distance_cattle_transported' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'seasonal_fertiliser' => false, + 'areas' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'cottonseed_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'manure_management_milking_cows' => false, + 'manure_management_other_dairy_cows' => false, + 'emissions_allocation_to_red_meat_production' => false, + 'truck_type' => false, + 'distance_cattle_transported' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'seasonal_fertiliser' => 'seasonalFertiliser', + 'areas' => 'areas', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'cottonseed_feed' => 'cottonseedFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'manure_management_milking_cows' => 'manureManagementMilkingCows', + 'manure_management_other_dairy_cows' => 'manureManagementOtherDairyCows', + 'emissions_allocation_to_red_meat_production' => 'emissionsAllocationToRedMeatProduction', + 'truck_type' => 'truckType', + 'distance_cattle_transported' => 'distanceCattleTransported' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'seasonal_fertiliser' => 'setSeasonalFertiliser', + 'areas' => 'setAreas', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'cottonseed_feed' => 'setCottonseedFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'manure_management_milking_cows' => 'setManureManagementMilkingCows', + 'manure_management_other_dairy_cows' => 'setManureManagementOtherDairyCows', + 'emissions_allocation_to_red_meat_production' => 'setEmissionsAllocationToRedMeatProduction', + 'truck_type' => 'setTruckType', + 'distance_cattle_transported' => 'setDistanceCattleTransported' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'seasonal_fertiliser' => 'getSeasonalFertiliser', + 'areas' => 'getAreas', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'cottonseed_feed' => 'getCottonseedFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'manure_management_milking_cows' => 'getManureManagementMilkingCows', + 'manure_management_other_dairy_cows' => 'getManureManagementOtherDairyCows', + 'emissions_allocation_to_red_meat_production' => 'getEmissionsAllocationToRedMeatProduction', + 'truck_type' => 'getTruckType', + 'distance_cattle_transported' => 'getDistanceCattleTransported' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TRUCK_TYPE__4_DECK_TRAILER = '4 Deck Trailer'; + public const TRUCK_TYPE__6_DECK_TRAILER = '6 Deck Trailer'; + public const TRUCK_TYPE_B_DOUBLE = 'B-Double'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTruckTypeAllowableValues() + { + return [ + self::TRUCK_TYPE__4_DECK_TRAILER, + self::TRUCK_TYPE__6_DECK_TRAILER, + self::TRUCK_TYPE_B_DOUBLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('seasonal_fertiliser', $data ?? [], null); + $this->setIfExists('areas', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('cottonseed_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('manure_management_milking_cows', $data ?? [], null); + $this->setIfExists('manure_management_other_dairy_cows', $data ?? [], null); + $this->setIfExists('emissions_allocation_to_red_meat_production', $data ?? [], null); + $this->setIfExists('truck_type', $data ?? [], null); + $this->setIfExists('distance_cattle_transported', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['seasonal_fertiliser'] === null) { + $invalidProperties[] = "'seasonal_fertiliser' can't be null"; + } + if ($this->container['areas'] === null) { + $invalidProperties[] = "'areas' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['cottonseed_feed'] === null) { + $invalidProperties[] = "'cottonseed_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['manure_management_milking_cows'] === null) { + $invalidProperties[] = "'manure_management_milking_cows' can't be null"; + } + if ($this->container['manure_management_other_dairy_cows'] === null) { + $invalidProperties[] = "'manure_management_other_dairy_cows' can't be null"; + } + if ($this->container['emissions_allocation_to_red_meat_production'] === null) { + $invalidProperties[] = "'emissions_allocation_to_red_meat_production' can't be null"; + } + if (($this->container['emissions_allocation_to_red_meat_production'] > 1)) { + $invalidProperties[] = "invalid value for 'emissions_allocation_to_red_meat_production', must be smaller than or equal to 1."; + } + + if (($this->container['emissions_allocation_to_red_meat_production'] < 0)) { + $invalidProperties[] = "invalid value for 'emissions_allocation_to_red_meat_production', must be bigger than or equal to 0."; + } + + if ($this->container['truck_type'] === null) { + $invalidProperties[] = "'truck_type' can't be null"; + } + $allowedValues = $this->getTruckTypeAllowableValues(); + if (!is_null($this->container['truck_type']) && !in_array($this->container['truck_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'truck_type', must be one of '%s'", + $this->container['truck_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['distance_cattle_transported'] === null) { + $invalidProperties[] = "'distance_cattle_transported' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets seasonal_fertiliser + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliser + */ + public function getSeasonalFertiliser() + { + return $this->container['seasonal_fertiliser']; + } + + /** + * Sets seasonal_fertiliser + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliser $seasonal_fertiliser seasonal_fertiliser + * + * @return self + */ + public function setSeasonalFertiliser($seasonal_fertiliser) + { + if (is_null($seasonal_fertiliser)) { + throw new \InvalidArgumentException('non-nullable seasonal_fertiliser cannot be null'); + } + $this->container['seasonal_fertiliser'] = $seasonal_fertiliser; + + return $this; + } + + /** + * Gets areas + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerAreas + */ + public function getAreas() + { + return $this->container['areas']; + } + + /** + * Sets areas + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerAreas $areas areas + * + * @return self + */ + public function setAreas($areas) + { + if (is_null($areas)) { + throw new \InvalidArgumentException('non-nullable areas cannot be null'); + } + $this->container['areas'] = $areas; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostDairyRequestDairyInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostDairyRequestDairyInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets cottonseed_feed + * + * @return float + */ + public function getCottonseedFeed() + { + return $this->container['cottonseed_feed']; + } + + /** + * Sets cottonseed_feed + * + * @param float $cottonseed_feed Cotton seed purchased for cattle feed in tonnes + * + * @return self + */ + public function setCottonseedFeed($cottonseed_feed) + { + if (is_null($cottonseed_feed)) { + throw new \InvalidArgumentException('non-nullable cottonseed_feed cannot be null'); + } + $this->container['cottonseed_feed'] = $cottonseed_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets manure_management_milking_cows + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows + */ + public function getManureManagementMilkingCows() + { + return $this->container['manure_management_milking_cows']; + } + + /** + * Sets manure_management_milking_cows + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows $manure_management_milking_cows manure_management_milking_cows + * + * @return self + */ + public function setManureManagementMilkingCows($manure_management_milking_cows) + { + if (is_null($manure_management_milking_cows)) { + throw new \InvalidArgumentException('non-nullable manure_management_milking_cows cannot be null'); + } + $this->container['manure_management_milking_cows'] = $manure_management_milking_cows; + + return $this; + } + + /** + * Gets manure_management_other_dairy_cows + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows + */ + public function getManureManagementOtherDairyCows() + { + return $this->container['manure_management_other_dairy_cows']; + } + + /** + * Sets manure_management_other_dairy_cows + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerManureManagementMilkingCows $manure_management_other_dairy_cows manure_management_other_dairy_cows + * + * @return self + */ + public function setManureManagementOtherDairyCows($manure_management_other_dairy_cows) + { + if (is_null($manure_management_other_dairy_cows)) { + throw new \InvalidArgumentException('non-nullable manure_management_other_dairy_cows cannot be null'); + } + $this->container['manure_management_other_dairy_cows'] = $manure_management_other_dairy_cows; + + return $this; + } + + /** + * Gets emissions_allocation_to_red_meat_production + * + * @return float + */ + public function getEmissionsAllocationToRedMeatProduction() + { + return $this->container['emissions_allocation_to_red_meat_production']; + } + + /** + * Sets emissions_allocation_to_red_meat_production + * + * @param float $emissions_allocation_to_red_meat_production Allocation as a fraction, from 0 to 1 + * + * @return self + */ + public function setEmissionsAllocationToRedMeatProduction($emissions_allocation_to_red_meat_production) + { + if (is_null($emissions_allocation_to_red_meat_production)) { + throw new \InvalidArgumentException('non-nullable emissions_allocation_to_red_meat_production cannot be null'); + } + + if (($emissions_allocation_to_red_meat_production > 1)) { + throw new \InvalidArgumentException('invalid value for $emissions_allocation_to_red_meat_production when calling PostDairyRequestDairyInner., must be smaller than or equal to 1.'); + } + if (($emissions_allocation_to_red_meat_production < 0)) { + throw new \InvalidArgumentException('invalid value for $emissions_allocation_to_red_meat_production when calling PostDairyRequestDairyInner., must be bigger than or equal to 0.'); + } + + $this->container['emissions_allocation_to_red_meat_production'] = $emissions_allocation_to_red_meat_production; + + return $this; + } + + /** + * Gets truck_type + * + * @return string + */ + public function getTruckType() + { + return $this->container['truck_type']; + } + + /** + * Sets truck_type + * + * @param string $truck_type Type of truck used for cattle transport + * + * @return self + */ + public function setTruckType($truck_type) + { + if (is_null($truck_type)) { + throw new \InvalidArgumentException('non-nullable truck_type cannot be null'); + } + $allowedValues = $this->getTruckTypeAllowableValues(); + if (!in_array($truck_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'truck_type', must be one of '%s'", + $truck_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['truck_type'] = $truck_type; + + return $this; + } + + /** + * Gets distance_cattle_transported + * + * @return float + */ + public function getDistanceCattleTransported() + { + return $this->container['distance_cattle_transported']; + } + + /** + * Sets distance_cattle_transported + * + * @param float $distance_cattle_transported Distance cattle are transported between farms, in km (kilometres) + * + * @return self + */ + public function setDistanceCattleTransported($distance_cattle_transported) + { + if (is_null($distance_cattle_transported)) { + throw new \InvalidArgumentException('non-nullable distance_cattle_transported cannot be null'); + } + $this->container['distance_cattle_transported'] = $distance_cattle_transported; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerAreas.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerAreas.php new file mode 100644 index 00000000..5a824a2f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerAreas.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerAreas implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_areas'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cropped_dryland' => 'float', + 'cropped_irrigated' => 'float', + 'improved_pasture_dryland' => 'float', + 'improved_pasture_irrigated' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cropped_dryland' => null, + 'cropped_irrigated' => null, + 'improved_pasture_dryland' => null, + 'improved_pasture_irrigated' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'cropped_dryland' => false, + 'cropped_irrigated' => false, + 'improved_pasture_dryland' => false, + 'improved_pasture_irrigated' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cropped_dryland' => 'croppedDryland', + 'cropped_irrigated' => 'croppedIrrigated', + 'improved_pasture_dryland' => 'improvedPastureDryland', + 'improved_pasture_irrigated' => 'improvedPastureIrrigated' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cropped_dryland' => 'setCroppedDryland', + 'cropped_irrigated' => 'setCroppedIrrigated', + 'improved_pasture_dryland' => 'setImprovedPastureDryland', + 'improved_pasture_irrigated' => 'setImprovedPastureIrrigated' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cropped_dryland' => 'getCroppedDryland', + 'cropped_irrigated' => 'getCroppedIrrigated', + 'improved_pasture_dryland' => 'getImprovedPastureDryland', + 'improved_pasture_irrigated' => 'getImprovedPastureIrrigated' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('cropped_dryland', $data ?? [], 0); + $this->setIfExists('cropped_irrigated', $data ?? [], 0); + $this->setIfExists('improved_pasture_dryland', $data ?? [], 0); + $this->setIfExists('improved_pasture_irrigated', $data ?? [], 0); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['cropped_dryland'] === null) { + $invalidProperties[] = "'cropped_dryland' can't be null"; + } + if ($this->container['cropped_irrigated'] === null) { + $invalidProperties[] = "'cropped_irrigated' can't be null"; + } + if ($this->container['improved_pasture_dryland'] === null) { + $invalidProperties[] = "'improved_pasture_dryland' can't be null"; + } + if ($this->container['improved_pasture_irrigated'] === null) { + $invalidProperties[] = "'improved_pasture_irrigated' 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 cropped_dryland + * + * @return float + */ + public function getCroppedDryland() + { + return $this->container['cropped_dryland']; + } + + /** + * Sets cropped_dryland + * + * @param float $cropped_dryland cropped_dryland + * + * @return self + */ + public function setCroppedDryland($cropped_dryland) + { + if (is_null($cropped_dryland)) { + throw new \InvalidArgumentException('non-nullable cropped_dryland cannot be null'); + } + $this->container['cropped_dryland'] = $cropped_dryland; + + return $this; + } + + /** + * Gets cropped_irrigated + * + * @return float + */ + public function getCroppedIrrigated() + { + return $this->container['cropped_irrigated']; + } + + /** + * Sets cropped_irrigated + * + * @param float $cropped_irrigated cropped_irrigated + * + * @return self + */ + public function setCroppedIrrigated($cropped_irrigated) + { + if (is_null($cropped_irrigated)) { + throw new \InvalidArgumentException('non-nullable cropped_irrigated cannot be null'); + } + $this->container['cropped_irrigated'] = $cropped_irrigated; + + return $this; + } + + /** + * Gets improved_pasture_dryland + * + * @return float + */ + public function getImprovedPastureDryland() + { + return $this->container['improved_pasture_dryland']; + } + + /** + * Sets improved_pasture_dryland + * + * @param float $improved_pasture_dryland improved_pasture_dryland + * + * @return self + */ + public function setImprovedPastureDryland($improved_pasture_dryland) + { + if (is_null($improved_pasture_dryland)) { + throw new \InvalidArgumentException('non-nullable improved_pasture_dryland cannot be null'); + } + $this->container['improved_pasture_dryland'] = $improved_pasture_dryland; + + return $this; + } + + /** + * Gets improved_pasture_irrigated + * + * @return float + */ + public function getImprovedPastureIrrigated() + { + return $this->container['improved_pasture_irrigated']; + } + + /** + * Sets improved_pasture_irrigated + * + * @param float $improved_pasture_irrigated improved_pasture_irrigated + * + * @return self + */ + public function setImprovedPastureIrrigated($improved_pasture_irrigated) + { + if (is_null($improved_pasture_irrigated)) { + throw new \InvalidArgumentException('non-nullable improved_pasture_irrigated cannot be null'); + } + $this->container['improved_pasture_irrigated'] = $improved_pasture_irrigated; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClasses.php new file mode 100644 index 00000000..9a342773 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClasses.php @@ -0,0 +1,562 @@ + + */ +class PostDairyRequestDairyInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'milking_cows' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCows', + 'heifers_lt1' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersLt1', + 'heifers_gt1' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersGt1', + 'dairy_bulls_lt1' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsLt1', + 'dairy_bulls_gt1' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsGt1' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'milking_cows' => null, + 'heifers_lt1' => null, + 'heifers_gt1' => null, + 'dairy_bulls_lt1' => null, + 'dairy_bulls_gt1' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'milking_cows' => false, + 'heifers_lt1' => false, + 'heifers_gt1' => false, + 'dairy_bulls_lt1' => false, + 'dairy_bulls_gt1' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'milking_cows' => 'milkingCows', + 'heifers_lt1' => 'heifersLt1', + 'heifers_gt1' => 'heifersGt1', + 'dairy_bulls_lt1' => 'dairyBullsLt1', + 'dairy_bulls_gt1' => 'dairyBullsGt1' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'milking_cows' => 'setMilkingCows', + 'heifers_lt1' => 'setHeifersLt1', + 'heifers_gt1' => 'setHeifersGt1', + 'dairy_bulls_lt1' => 'setDairyBullsLt1', + 'dairy_bulls_gt1' => 'setDairyBullsGt1' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'milking_cows' => 'getMilkingCows', + 'heifers_lt1' => 'getHeifersLt1', + 'heifers_gt1' => 'getHeifersGt1', + 'dairy_bulls_lt1' => 'getDairyBullsLt1', + 'dairy_bulls_gt1' => 'getDairyBullsGt1' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('milking_cows', $data ?? [], null); + $this->setIfExists('heifers_lt1', $data ?? [], null); + $this->setIfExists('heifers_gt1', $data ?? [], null); + $this->setIfExists('dairy_bulls_lt1', $data ?? [], null); + $this->setIfExists('dairy_bulls_gt1', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['milking_cows'] === null) { + $invalidProperties[] = "'milking_cows' can't be null"; + } + if ($this->container['heifers_lt1'] === null) { + $invalidProperties[] = "'heifers_lt1' can't be null"; + } + if ($this->container['heifers_gt1'] === null) { + $invalidProperties[] = "'heifers_gt1' can't be null"; + } + if ($this->container['dairy_bulls_lt1'] === null) { + $invalidProperties[] = "'dairy_bulls_lt1' can't be null"; + } + if ($this->container['dairy_bulls_gt1'] === null) { + $invalidProperties[] = "'dairy_bulls_gt1' 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 milking_cows + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCows + */ + public function getMilkingCows() + { + return $this->container['milking_cows']; + } + + /** + * Sets milking_cows + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCows $milking_cows milking_cows + * + * @return self + */ + public function setMilkingCows($milking_cows) + { + if (is_null($milking_cows)) { + throw new \InvalidArgumentException('non-nullable milking_cows cannot be null'); + } + $this->container['milking_cows'] = $milking_cows; + + return $this; + } + + /** + * Gets heifers_lt1 + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersLt1 + */ + public function getHeifersLt1() + { + return $this->container['heifers_lt1']; + } + + /** + * Sets heifers_lt1 + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersLt1 $heifers_lt1 heifers_lt1 + * + * @return self + */ + public function setHeifersLt1($heifers_lt1) + { + if (is_null($heifers_lt1)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1 cannot be null'); + } + $this->container['heifers_lt1'] = $heifers_lt1; + + return $this; + } + + /** + * Gets heifers_gt1 + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersGt1 + */ + public function getHeifersGt1() + { + return $this->container['heifers_gt1']; + } + + /** + * Sets heifers_gt1 + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesHeifersGt1 $heifers_gt1 heifers_gt1 + * + * @return self + */ + public function setHeifersGt1($heifers_gt1) + { + if (is_null($heifers_gt1)) { + throw new \InvalidArgumentException('non-nullable heifers_gt1 cannot be null'); + } + $this->container['heifers_gt1'] = $heifers_gt1; + + return $this; + } + + /** + * Gets dairy_bulls_lt1 + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsLt1 + */ + public function getDairyBullsLt1() + { + return $this->container['dairy_bulls_lt1']; + } + + /** + * Sets dairy_bulls_lt1 + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsLt1 $dairy_bulls_lt1 dairy_bulls_lt1 + * + * @return self + */ + public function setDairyBullsLt1($dairy_bulls_lt1) + { + if (is_null($dairy_bulls_lt1)) { + throw new \InvalidArgumentException('non-nullable dairy_bulls_lt1 cannot be null'); + } + $this->container['dairy_bulls_lt1'] = $dairy_bulls_lt1; + + return $this; + } + + /** + * Gets dairy_bulls_gt1 + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsGt1 + */ + public function getDairyBullsGt1() + { + return $this->container['dairy_bulls_gt1']; + } + + /** + * Sets dairy_bulls_gt1 + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesDairyBullsGt1 $dairy_bulls_gt1 dairy_bulls_gt1 + * + * @return self + */ + public function setDairyBullsGt1($dairy_bulls_gt1) + { + if (is_null($dairy_bulls_gt1)) { + throw new \InvalidArgumentException('non-nullable dairy_bulls_gt1 cannot be null'); + } + $this->container['dairy_bulls_gt1'] = $dairy_bulls_gt1; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsGt1.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsGt1.php new file mode 100644 index 00000000..ec5269dd --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsGt1.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerClassesDairyBullsGt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_dairyBullsGt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsLt1.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsLt1.php new file mode 100644 index 00000000..9bd366ec --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesDairyBullsLt1.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerClassesDairyBullsLt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_dairyBullsLt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersGt1.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersGt1.php new file mode 100644 index 00000000..acaef7fe --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersGt1.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerClassesHeifersGt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_heifersGt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersLt1.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersLt1.php new file mode 100644 index 00000000..41b867a6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesHeifersLt1.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerClassesHeifersLt1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_heifersLt1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCows.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCows.php new file mode 100644 index 00000000..2788a2c1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCows.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerClassesMilkingCows implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_milkingCows'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerClassesMilkingCowsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.php new file mode 100644 index 00000000..7ef2eb27 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.php @@ -0,0 +1,589 @@ + + */ +class PostDairyRequestDairyInnerClassesMilkingCowsAutumn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_classes_milkingCows_autumn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'liveweight' => 'float', + 'liveweight_gain' => 'float', + 'crude_protein' => 'float', + 'dry_matter_digestibility' => 'float', + 'milk_production' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'liveweight' => null, + 'liveweight_gain' => null, + 'crude_protein' => null, + 'dry_matter_digestibility' => null, + 'milk_production' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'liveweight' => false, + 'liveweight_gain' => false, + 'crude_protein' => false, + 'dry_matter_digestibility' => false, + 'milk_production' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head', + 'liveweight' => 'liveweight', + 'liveweight_gain' => 'liveweightGain', + 'crude_protein' => 'crudeProtein', + 'dry_matter_digestibility' => 'dryMatterDigestibility', + 'milk_production' => 'milkProduction' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'liveweight' => 'setLiveweight', + 'liveweight_gain' => 'setLiveweightGain', + 'crude_protein' => 'setCrudeProtein', + 'dry_matter_digestibility' => 'setDryMatterDigestibility', + 'milk_production' => 'setMilkProduction' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'liveweight' => 'getLiveweight', + 'liveweight_gain' => 'getLiveweightGain', + 'crude_protein' => 'getCrudeProtein', + 'dry_matter_digestibility' => 'getDryMatterDigestibility', + 'milk_production' => 'getMilkProduction' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('liveweight', $data ?? [], null); + $this->setIfExists('liveweight_gain', $data ?? [], null); + $this->setIfExists('crude_protein', $data ?? [], null); + $this->setIfExists('dry_matter_digestibility', $data ?? [], null); + $this->setIfExists('milk_production', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['liveweight'] === null) { + $invalidProperties[] = "'liveweight' can't be null"; + } + if ($this->container['liveweight_gain'] === null) { + $invalidProperties[] = "'liveweight_gain' 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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets liveweight + * + * @return float + */ + public function getLiveweight() + { + return $this->container['liveweight']; + } + + /** + * Sets liveweight + * + * @param float $liveweight Average liveweight of animals in kg/head (kilogram per head) + * + * @return self + */ + public function setLiveweight($liveweight) + { + if (is_null($liveweight)) { + throw new \InvalidArgumentException('non-nullable liveweight cannot be null'); + } + $this->container['liveweight'] = $liveweight; + + return $this; + } + + /** + * Gets liveweight_gain + * + * @return float + */ + public function getLiveweightGain() + { + return $this->container['liveweight_gain']; + } + + /** + * Sets liveweight_gain + * + * @param float $liveweight_gain Average liveweight gain in kg/day (kilogram per day) + * + * @return self + */ + public function setLiveweightGain($liveweight_gain) + { + if (is_null($liveweight_gain)) { + throw new \InvalidArgumentException('non-nullable liveweight_gain cannot be null'); + } + $this->container['liveweight_gain'] = $liveweight_gain; + + return $this; + } + + /** + * Gets crude_protein + * + * @return float|null + */ + public function getCrudeProtein() + { + return $this->container['crude_protein']; + } + + /** + * Sets crude_protein + * + * @param float|null $crude_protein Crude protein percent, between 0 and 100. Note: If no value is provided, zero will be assumed. This will result in large, negative output values. This input will become mandatory in a future version. + * + * @return self + */ + public function setCrudeProtein($crude_protein) + { + if (is_null($crude_protein)) { + throw new \InvalidArgumentException('non-nullable crude_protein cannot be null'); + } + $this->container['crude_protein'] = $crude_protein; + + return $this; + } + + /** + * Gets dry_matter_digestibility + * + * @return float|null + */ + public function getDryMatterDigestibility() + { + return $this->container['dry_matter_digestibility']; + } + + /** + * Sets dry_matter_digestibility + * + * @param float|null $dry_matter_digestibility Dry matter digestibility percent, between 0 and 100. Note: If no value is provided, zero will be assumed. This will result in large, negative output values. This input will become mandatory in a future version. + * + * @return self + */ + public function setDryMatterDigestibility($dry_matter_digestibility) + { + if (is_null($dry_matter_digestibility)) { + throw new \InvalidArgumentException('non-nullable dry_matter_digestibility cannot be null'); + } + $this->container['dry_matter_digestibility'] = $dry_matter_digestibility; + + return $this; + } + + /** + * Gets milk_production + * + * @return float|null + */ + public function getMilkProduction() + { + return $this->container['milk_production']; + } + + /** + * Sets milk_production + * + * @param float|null $milk_production Milk produced in L/day/head (litres per day per head) + * + * @return self + */ + public function setMilkProduction($milk_production) + { + if (is_null($milk_production)) { + throw new \InvalidArgumentException('non-nullable milk_production cannot be null'); + } + $this->container['milk_production'] = $milk_production; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerManureManagementMilkingCows.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerManureManagementMilkingCows.php new file mode 100644 index 00000000..ed9b2a78 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerManureManagementMilkingCows.php @@ -0,0 +1,642 @@ + + */ +class PostDairyRequestDairyInnerManureManagementMilkingCows implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_manureManagementMilkingCows'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'pasture' => 'float', + 'anaerobic_lagoon' => 'float', + 'sump_and_dispersal' => 'float', + 'drain_to_paddocks' => 'float', + 'soild_storage' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'pasture' => null, + 'anaerobic_lagoon' => null, + 'sump_and_dispersal' => null, + 'drain_to_paddocks' => null, + 'soild_storage' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'pasture' => false, + 'anaerobic_lagoon' => false, + 'sump_and_dispersal' => false, + 'drain_to_paddocks' => false, + 'soild_storage' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'pasture' => 'pasture', + 'anaerobic_lagoon' => 'anaerobicLagoon', + 'sump_and_dispersal' => 'sumpAndDispersal', + 'drain_to_paddocks' => 'drainToPaddocks', + 'soild_storage' => 'soildStorage' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'pasture' => 'setPasture', + 'anaerobic_lagoon' => 'setAnaerobicLagoon', + 'sump_and_dispersal' => 'setSumpAndDispersal', + 'drain_to_paddocks' => 'setDrainToPaddocks', + 'soild_storage' => 'setSoildStorage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'pasture' => 'getPasture', + 'anaerobic_lagoon' => 'getAnaerobicLagoon', + 'sump_and_dispersal' => 'getSumpAndDispersal', + 'drain_to_paddocks' => 'getDrainToPaddocks', + 'soild_storage' => 'getSoildStorage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('pasture', $data ?? [], null); + $this->setIfExists('anaerobic_lagoon', $data ?? [], null); + $this->setIfExists('sump_and_dispersal', $data ?? [], null); + $this->setIfExists('drain_to_paddocks', $data ?? [], null); + $this->setIfExists('soild_storage', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['pasture'] === null) { + $invalidProperties[] = "'pasture' can't be null"; + } + if (($this->container['pasture'] > 100)) { + $invalidProperties[] = "invalid value for 'pasture', must be smaller than or equal to 100."; + } + + if (($this->container['pasture'] < 0)) { + $invalidProperties[] = "invalid value for 'pasture', must be bigger than or equal to 0."; + } + + if ($this->container['anaerobic_lagoon'] === null) { + $invalidProperties[] = "'anaerobic_lagoon' can't be null"; + } + if (($this->container['anaerobic_lagoon'] > 100)) { + $invalidProperties[] = "invalid value for 'anaerobic_lagoon', must be smaller than or equal to 100."; + } + + if (($this->container['anaerobic_lagoon'] < 0)) { + $invalidProperties[] = "invalid value for 'anaerobic_lagoon', must be bigger than or equal to 0."; + } + + if ($this->container['sump_and_dispersal'] === null) { + $invalidProperties[] = "'sump_and_dispersal' can't be null"; + } + if (($this->container['sump_and_dispersal'] > 100)) { + $invalidProperties[] = "invalid value for 'sump_and_dispersal', must be smaller than or equal to 100."; + } + + if (($this->container['sump_and_dispersal'] < 0)) { + $invalidProperties[] = "invalid value for 'sump_and_dispersal', must be bigger than or equal to 0."; + } + + if ($this->container['drain_to_paddocks'] === null) { + $invalidProperties[] = "'drain_to_paddocks' can't be null"; + } + if (($this->container['drain_to_paddocks'] > 100)) { + $invalidProperties[] = "invalid value for 'drain_to_paddocks', must be smaller than or equal to 100."; + } + + if (($this->container['drain_to_paddocks'] < 0)) { + $invalidProperties[] = "invalid value for 'drain_to_paddocks', must be bigger than or equal to 0."; + } + + if ($this->container['soild_storage'] === null) { + $invalidProperties[] = "'soild_storage' can't be null"; + } + if (($this->container['soild_storage'] > 100)) { + $invalidProperties[] = "invalid value for 'soild_storage', must be smaller than or equal to 100."; + } + + if (($this->container['soild_storage'] < 0)) { + $invalidProperties[] = "invalid value for 'soild_storage', 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 pasture + * + * @return float + */ + public function getPasture() + { + return $this->container['pasture']; + } + + /** + * Sets pasture + * + * @param float $pasture pasture + * + * @return self + */ + public function setPasture($pasture) + { + if (is_null($pasture)) { + throw new \InvalidArgumentException('non-nullable pasture cannot be null'); + } + + if (($pasture > 100)) { + throw new \InvalidArgumentException('invalid value for $pasture when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be smaller than or equal to 100.'); + } + if (($pasture < 0)) { + throw new \InvalidArgumentException('invalid value for $pasture when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be bigger than or equal to 0.'); + } + + $this->container['pasture'] = $pasture; + + return $this; + } + + /** + * Gets anaerobic_lagoon + * + * @return float + */ + public function getAnaerobicLagoon() + { + return $this->container['anaerobic_lagoon']; + } + + /** + * Sets anaerobic_lagoon + * + * @param float $anaerobic_lagoon anaerobic_lagoon + * + * @return self + */ + public function setAnaerobicLagoon($anaerobic_lagoon) + { + if (is_null($anaerobic_lagoon)) { + throw new \InvalidArgumentException('non-nullable anaerobic_lagoon cannot be null'); + } + + if (($anaerobic_lagoon > 100)) { + throw new \InvalidArgumentException('invalid value for $anaerobic_lagoon when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be smaller than or equal to 100.'); + } + if (($anaerobic_lagoon < 0)) { + throw new \InvalidArgumentException('invalid value for $anaerobic_lagoon when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be bigger than or equal to 0.'); + } + + $this->container['anaerobic_lagoon'] = $anaerobic_lagoon; + + return $this; + } + + /** + * Gets sump_and_dispersal + * + * @return float + */ + public function getSumpAndDispersal() + { + return $this->container['sump_and_dispersal']; + } + + /** + * Sets sump_and_dispersal + * + * @param float $sump_and_dispersal sump_and_dispersal + * + * @return self + */ + public function setSumpAndDispersal($sump_and_dispersal) + { + if (is_null($sump_and_dispersal)) { + throw new \InvalidArgumentException('non-nullable sump_and_dispersal cannot be null'); + } + + if (($sump_and_dispersal > 100)) { + throw new \InvalidArgumentException('invalid value for $sump_and_dispersal when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be smaller than or equal to 100.'); + } + if (($sump_and_dispersal < 0)) { + throw new \InvalidArgumentException('invalid value for $sump_and_dispersal when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be bigger than or equal to 0.'); + } + + $this->container['sump_and_dispersal'] = $sump_and_dispersal; + + return $this; + } + + /** + * Gets drain_to_paddocks + * + * @return float + */ + public function getDrainToPaddocks() + { + return $this->container['drain_to_paddocks']; + } + + /** + * Sets drain_to_paddocks + * + * @param float $drain_to_paddocks drain_to_paddocks + * + * @return self + */ + public function setDrainToPaddocks($drain_to_paddocks) + { + if (is_null($drain_to_paddocks)) { + throw new \InvalidArgumentException('non-nullable drain_to_paddocks cannot be null'); + } + + if (($drain_to_paddocks > 100)) { + throw new \InvalidArgumentException('invalid value for $drain_to_paddocks when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be smaller than or equal to 100.'); + } + if (($drain_to_paddocks < 0)) { + throw new \InvalidArgumentException('invalid value for $drain_to_paddocks when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be bigger than or equal to 0.'); + } + + $this->container['drain_to_paddocks'] = $drain_to_paddocks; + + return $this; + } + + /** + * Gets soild_storage + * + * @return float + */ + public function getSoildStorage() + { + return $this->container['soild_storage']; + } + + /** + * Sets soild_storage + * + * @param float $soild_storage soild_storage + * + * @return self + */ + public function setSoildStorage($soild_storage) + { + if (is_null($soild_storage)) { + throw new \InvalidArgumentException('non-nullable soild_storage cannot be null'); + } + + if (($soild_storage > 100)) { + throw new \InvalidArgumentException('invalid value for $soild_storage when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be smaller than or equal to 100.'); + } + if (($soild_storage < 0)) { + throw new \InvalidArgumentException('invalid value for $soild_storage when calling PostDairyRequestDairyInnerManureManagementMilkingCows., must be bigger than or equal to 0.'); + } + + $this->container['soild_storage'] = $soild_storage; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliser.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliser.php new file mode 100644 index 00000000..2a2465cb --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliser.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerSeasonalFertiliser implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_seasonalFertiliser'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn', + 'winter' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn', + 'spring' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn', + 'summer' => '\OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostDairyRequestDairyInnerSeasonalFertiliserAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.php new file mode 100644 index 00000000..c5946789 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.php @@ -0,0 +1,525 @@ + + */ +class PostDairyRequestDairyInnerSeasonalFertiliserAutumn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_dairy_inner_seasonalFertiliser_autumn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'crops_irrigated' => 'float', + 'crops_dryland' => 'float', + 'pasture_irrigated' => 'float', + 'pasture_dryland' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'crops_irrigated' => null, + 'crops_dryland' => null, + 'pasture_irrigated' => null, + 'pasture_dryland' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'crops_irrigated' => false, + 'crops_dryland' => false, + 'pasture_irrigated' => false, + 'pasture_dryland' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'crops_irrigated' => 'cropsIrrigated', + 'crops_dryland' => 'cropsDryland', + 'pasture_irrigated' => 'pastureIrrigated', + 'pasture_dryland' => 'pastureDryland' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'crops_irrigated' => 'setCropsIrrigated', + 'crops_dryland' => 'setCropsDryland', + 'pasture_irrigated' => 'setPastureIrrigated', + 'pasture_dryland' => 'setPastureDryland' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'crops_irrigated' => 'getCropsIrrigated', + 'crops_dryland' => 'getCropsDryland', + 'pasture_irrigated' => 'getPastureIrrigated', + 'pasture_dryland' => 'getPastureDryland' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('crops_irrigated', $data ?? [], null); + $this->setIfExists('crops_dryland', $data ?? [], null); + $this->setIfExists('pasture_irrigated', $data ?? [], null); + $this->setIfExists('pasture_dryland', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['crops_irrigated'] === null) { + $invalidProperties[] = "'crops_irrigated' can't be null"; + } + if ($this->container['crops_dryland'] === null) { + $invalidProperties[] = "'crops_dryland' can't be null"; + } + if ($this->container['pasture_irrigated'] === null) { + $invalidProperties[] = "'pasture_irrigated' can't be null"; + } + if ($this->container['pasture_dryland'] === null) { + $invalidProperties[] = "'pasture_dryland' 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 crops_irrigated + * + * @return float + */ + public function getCropsIrrigated() + { + return $this->container['crops_irrigated']; + } + + /** + * Sets crops_irrigated + * + * @param float $crops_irrigated crops_irrigated + * + * @return self + */ + public function setCropsIrrigated($crops_irrigated) + { + if (is_null($crops_irrigated)) { + throw new \InvalidArgumentException('non-nullable crops_irrigated cannot be null'); + } + $this->container['crops_irrigated'] = $crops_irrigated; + + return $this; + } + + /** + * Gets crops_dryland + * + * @return float + */ + public function getCropsDryland() + { + return $this->container['crops_dryland']; + } + + /** + * Sets crops_dryland + * + * @param float $crops_dryland crops_dryland + * + * @return self + */ + public function setCropsDryland($crops_dryland) + { + if (is_null($crops_dryland)) { + throw new \InvalidArgumentException('non-nullable crops_dryland cannot be null'); + } + $this->container['crops_dryland'] = $crops_dryland; + + return $this; + } + + /** + * Gets pasture_irrigated + * + * @return float + */ + public function getPastureIrrigated() + { + return $this->container['pasture_irrigated']; + } + + /** + * Sets pasture_irrigated + * + * @param float $pasture_irrigated pasture_irrigated + * + * @return self + */ + public function setPastureIrrigated($pasture_irrigated) + { + if (is_null($pasture_irrigated)) { + throw new \InvalidArgumentException('non-nullable pasture_irrigated cannot be null'); + } + $this->container['pasture_irrigated'] = $pasture_irrigated; + + return $this; + } + + /** + * Gets pasture_dryland + * + * @return float + */ + public function getPastureDryland() + { + return $this->container['pasture_dryland']; + } + + /** + * Sets pasture_dryland + * + * @param float $pasture_dryland pasture_dryland + * + * @return self + */ + public function setPastureDryland($pasture_dryland) + { + if (is_null($pasture_dryland)) { + throw new \InvalidArgumentException('non-nullable pasture_dryland cannot be null'); + } + $this->container['pasture_dryland'] = $pasture_dryland; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDairyRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostDairyRequestVegetationInner.php new file mode 100644 index 00000000..d8aca822 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDairyRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostDairyRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_dairy_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'dairy_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'dairy_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'dairy_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'dairy_proportion' => 'dairyProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'dairy_proportion' => 'setDairyProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'dairy_proportion' => 'getDairyProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('dairy_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['dairy_proportion'] === null) { + $invalidProperties[] = "'dairy_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets dairy_proportion + * + * @return float[] + */ + public function getDairyProportion() + { + return $this->container['dairy_proportion']; + } + + /** + * Sets dairy_proportion + * + * @param float[] $dairy_proportion The proportion of the sequestration that is allocated to dairy + * + * @return self + */ + public function setDairyProportion($dairy_proportion) + { + if (is_null($dairy_proportion)) { + throw new \InvalidArgumentException('non-nullable dairy_proportion cannot be null'); + } + $this->container['dairy_proportion'] = $dairy_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeer200Response.php b/examples/php-api-client/api-client/lib/Model/PostDeer200Response.php new file mode 100644 index 00000000..3f047694 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeer200Response.php @@ -0,0 +1,636 @@ + + */ +class PostDeer200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostDeer200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostDeer200ResponseIntensities', + 'intermediate' => '\OpenAPI\Client\Model\PostDeer200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostDeer200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostDeer200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostDeer200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostDeer200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostDeer200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostDeer200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntensities.php new file mode 100644 index 00000000..b16268b2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostDeer200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'liveweight_produced_kg' => 'float', + 'deer_meat_excluding_sequestration' => 'float', + 'deer_meat_including_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'liveweight_produced_kg' => null, + 'deer_meat_excluding_sequestration' => null, + 'deer_meat_including_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'liveweight_produced_kg' => false, + 'deer_meat_excluding_sequestration' => false, + 'deer_meat_including_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'liveweight_produced_kg' => 'liveweightProducedKg', + 'deer_meat_excluding_sequestration' => 'deerMeatExcludingSequestration', + 'deer_meat_including_sequestration' => 'deerMeatIncludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'liveweight_produced_kg' => 'setLiveweightProducedKg', + 'deer_meat_excluding_sequestration' => 'setDeerMeatExcludingSequestration', + 'deer_meat_including_sequestration' => 'setDeerMeatIncludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'liveweight_produced_kg' => 'getLiveweightProducedKg', + 'deer_meat_excluding_sequestration' => 'getDeerMeatExcludingSequestration', + 'deer_meat_including_sequestration' => 'getDeerMeatIncludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('liveweight_produced_kg', $data ?? [], null); + $this->setIfExists('deer_meat_excluding_sequestration', $data ?? [], null); + $this->setIfExists('deer_meat_including_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['liveweight_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_produced_kg' can't be null"; + } + if ($this->container['deer_meat_excluding_sequestration'] === null) { + $invalidProperties[] = "'deer_meat_excluding_sequestration' can't be null"; + } + if ($this->container['deer_meat_including_sequestration'] === null) { + $invalidProperties[] = "'deer_meat_including_sequestration' 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 liveweight_produced_kg + * + * @return float + */ + public function getLiveweightProducedKg() + { + return $this->container['liveweight_produced_kg']; + } + + /** + * Sets liveweight_produced_kg + * + * @param float $liveweight_produced_kg Deer meat produced in kg liveweight + * + * @return self + */ + public function setLiveweightProducedKg($liveweight_produced_kg) + { + if (is_null($liveweight_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_produced_kg cannot be null'); + } + $this->container['liveweight_produced_kg'] = $liveweight_produced_kg; + + return $this; + } + + /** + * Gets deer_meat_excluding_sequestration + * + * @return float + */ + public function getDeerMeatExcludingSequestration() + { + return $this->container['deer_meat_excluding_sequestration']; + } + + /** + * Sets deer_meat_excluding_sequestration + * + * @param float $deer_meat_excluding_sequestration Deer meat (breeding herd) excluding sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setDeerMeatExcludingSequestration($deer_meat_excluding_sequestration) + { + if (is_null($deer_meat_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable deer_meat_excluding_sequestration cannot be null'); + } + $this->container['deer_meat_excluding_sequestration'] = $deer_meat_excluding_sequestration; + + return $this; + } + + /** + * Gets deer_meat_including_sequestration + * + * @return float + */ + public function getDeerMeatIncludingSequestration() + { + return $this->container['deer_meat_including_sequestration']; + } + + /** + * Sets deer_meat_including_sequestration + * + * @param float $deer_meat_including_sequestration Deer meat (breeding herd) including sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setDeerMeatIncludingSequestration($deer_meat_including_sequestration) + { + if (is_null($deer_meat_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable deer_meat_including_sequestration cannot be null'); + } + $this->container['deer_meat_including_sequestration'] = $deer_meat_including_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntermediateInner.php new file mode 100644 index 00000000..9468dae1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostDeer200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope3', + 'net' => '\OpenAPI\Client\Model\PostDeer200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostDeer200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostDeer200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostDeer200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostDeer200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostDeer200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseNet.php new file mode 100644 index 00000000..4c81acc6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeer200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostDeer200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequest.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequest.php new file mode 100644 index 00000000..f35c0792 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequest.php @@ -0,0 +1,573 @@ + + */ +class PostDeerRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'rainfall_above600' => 'bool', + 'deers' => '\OpenAPI\Client\Model\PostDeerRequestDeersInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostDeerRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'rainfall_above600' => null, + 'deers' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'rainfall_above600' => false, + 'deers' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'rainfall_above600' => 'rainfallAbove600', + 'deers' => 'deers', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'rainfall_above600' => 'setRainfallAbove600', + 'deers' => 'setDeers', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'rainfall_above600' => 'getRainfallAbove600', + 'deers' => 'getDeers', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('deers', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['deers'] === null) { + $invalidProperties[] = "'deers' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets deers + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInner[] + */ + public function getDeers() + { + return $this->container['deers']; + } + + /** + * Sets deers + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInner[] $deers deers + * + * @return self + */ + public function setDeers($deers) + { + if (is_null($deers)) { + throw new \InvalidArgumentException('non-nullable deers cannot be null'); + } + $this->container['deers'] = $deers; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostDeerRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostDeerRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInner.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInner.php new file mode 100644 index 00000000..1ac652c5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInner.php @@ -0,0 +1,1052 @@ + + */ +class PostDeerRequestDeersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'does_fawning' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerDoesFawning', + 'seasonal_fawning' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerSeasonalFawning' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'does_fawning' => null, + 'seasonal_fawning' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'does_fawning' => false, + 'seasonal_fawning' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'does_fawning' => 'doesFawning', + 'seasonal_fawning' => 'seasonalFawning' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'does_fawning' => 'setDoesFawning', + 'seasonal_fawning' => 'setSeasonalFawning' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'does_fawning' => 'getDoesFawning', + 'seasonal_fawning' => 'getSeasonalFawning' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('does_fawning', $data ?? [], null); + $this->setIfExists('seasonal_fawning', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['does_fawning'] === null) { + $invalidProperties[] = "'does_fawning' can't be null"; + } + if ($this->container['seasonal_fawning'] === null) { + $invalidProperties[] = "'seasonal_fawning' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostDeerRequestDeersInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostDeerRequestDeersInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets does_fawning + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerDoesFawning + */ + public function getDoesFawning() + { + return $this->container['does_fawning']; + } + + /** + * Sets does_fawning + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerDoesFawning $does_fawning does_fawning + * + * @return self + */ + public function setDoesFawning($does_fawning) + { + if (is_null($does_fawning)) { + throw new \InvalidArgumentException('non-nullable does_fawning cannot be null'); + } + $this->container['does_fawning'] = $does_fawning; + + return $this; + } + + /** + * Gets seasonal_fawning + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerSeasonalFawning + */ + public function getSeasonalFawning() + { + return $this->container['seasonal_fawning']; + } + + /** + * Sets seasonal_fawning + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerSeasonalFawning $seasonal_fawning seasonal_fawning + * + * @return self + */ + public function setSeasonalFawning($seasonal_fawning) + { + if (is_null($seasonal_fawning)) { + throw new \InvalidArgumentException('non-nullable seasonal_fawning cannot be null'); + } + $this->container['seasonal_fawning'] = $seasonal_fawning; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClasses.php new file mode 100644 index 00000000..2e422c6e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClasses.php @@ -0,0 +1,649 @@ + + */ +class PostDeerRequestDeersInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bucks' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBucks', + 'trade_bucks' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeBucks', + 'breeding_does' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBreedingDoes', + 'trade_does' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeDoes', + 'other_does' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesOtherDoes', + 'trade_other_does' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeOtherDoes', + 'fawn' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesFawn', + 'trade_fawn' => '\OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeFawn' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bucks' => null, + 'trade_bucks' => null, + 'breeding_does' => null, + 'trade_does' => null, + 'other_does' => null, + 'trade_other_does' => null, + 'fawn' => null, + 'trade_fawn' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bucks' => false, + 'trade_bucks' => false, + 'breeding_does' => false, + 'trade_does' => false, + 'other_does' => false, + 'trade_other_does' => false, + 'fawn' => false, + 'trade_fawn' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bucks' => 'bucks', + 'trade_bucks' => 'tradeBucks', + 'breeding_does' => 'breedingDoes', + 'trade_does' => 'tradeDoes', + 'other_does' => 'otherDoes', + 'trade_other_does' => 'tradeOtherDoes', + 'fawn' => 'fawn', + 'trade_fawn' => 'tradeFawn' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bucks' => 'setBucks', + 'trade_bucks' => 'setTradeBucks', + 'breeding_does' => 'setBreedingDoes', + 'trade_does' => 'setTradeDoes', + 'other_does' => 'setOtherDoes', + 'trade_other_does' => 'setTradeOtherDoes', + 'fawn' => 'setFawn', + 'trade_fawn' => 'setTradeFawn' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bucks' => 'getBucks', + 'trade_bucks' => 'getTradeBucks', + 'breeding_does' => 'getBreedingDoes', + 'trade_does' => 'getTradeDoes', + 'other_does' => 'getOtherDoes', + 'trade_other_does' => 'getTradeOtherDoes', + 'fawn' => 'getFawn', + 'trade_fawn' => 'getTradeFawn' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bucks', $data ?? [], null); + $this->setIfExists('trade_bucks', $data ?? [], null); + $this->setIfExists('breeding_does', $data ?? [], null); + $this->setIfExists('trade_does', $data ?? [], null); + $this->setIfExists('other_does', $data ?? [], null); + $this->setIfExists('trade_other_does', $data ?? [], null); + $this->setIfExists('fawn', $data ?? [], null); + $this->setIfExists('trade_fawn', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 bucks + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBucks|null + */ + public function getBucks() + { + return $this->container['bucks']; + } + + /** + * Sets bucks + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBucks|null $bucks bucks + * + * @return self + */ + public function setBucks($bucks) + { + if (is_null($bucks)) { + throw new \InvalidArgumentException('non-nullable bucks cannot be null'); + } + $this->container['bucks'] = $bucks; + + return $this; + } + + /** + * Gets trade_bucks + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeBucks|null + */ + public function getTradeBucks() + { + return $this->container['trade_bucks']; + } + + /** + * Sets trade_bucks + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeBucks|null $trade_bucks trade_bucks + * + * @return self + */ + public function setTradeBucks($trade_bucks) + { + if (is_null($trade_bucks)) { + throw new \InvalidArgumentException('non-nullable trade_bucks cannot be null'); + } + $this->container['trade_bucks'] = $trade_bucks; + + return $this; + } + + /** + * Gets breeding_does + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBreedingDoes|null + */ + public function getBreedingDoes() + { + return $this->container['breeding_does']; + } + + /** + * Sets breeding_does + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesBreedingDoes|null $breeding_does breeding_does + * + * @return self + */ + public function setBreedingDoes($breeding_does) + { + if (is_null($breeding_does)) { + throw new \InvalidArgumentException('non-nullable breeding_does cannot be null'); + } + $this->container['breeding_does'] = $breeding_does; + + return $this; + } + + /** + * Gets trade_does + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeDoes|null + */ + public function getTradeDoes() + { + return $this->container['trade_does']; + } + + /** + * Sets trade_does + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeDoes|null $trade_does trade_does + * + * @return self + */ + public function setTradeDoes($trade_does) + { + if (is_null($trade_does)) { + throw new \InvalidArgumentException('non-nullable trade_does cannot be null'); + } + $this->container['trade_does'] = $trade_does; + + return $this; + } + + /** + * Gets other_does + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesOtherDoes|null + */ + public function getOtherDoes() + { + return $this->container['other_does']; + } + + /** + * Sets other_does + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesOtherDoes|null $other_does other_does + * + * @return self + */ + public function setOtherDoes($other_does) + { + if (is_null($other_does)) { + throw new \InvalidArgumentException('non-nullable other_does cannot be null'); + } + $this->container['other_does'] = $other_does; + + return $this; + } + + /** + * Gets trade_other_does + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeOtherDoes|null + */ + public function getTradeOtherDoes() + { + return $this->container['trade_other_does']; + } + + /** + * Sets trade_other_does + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeOtherDoes|null $trade_other_does trade_other_does + * + * @return self + */ + public function setTradeOtherDoes($trade_other_does) + { + if (is_null($trade_other_does)) { + throw new \InvalidArgumentException('non-nullable trade_other_does cannot be null'); + } + $this->container['trade_other_does'] = $trade_other_does; + + return $this; + } + + /** + * Gets fawn + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesFawn|null + */ + public function getFawn() + { + return $this->container['fawn']; + } + + /** + * Sets fawn + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesFawn|null $fawn fawn + * + * @return self + */ + public function setFawn($fawn) + { + if (is_null($fawn)) { + throw new \InvalidArgumentException('non-nullable fawn cannot be null'); + } + $this->container['fawn'] = $fawn; + + return $this; + } + + /** + * Gets trade_fawn + * + * @return \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeFawn|null + */ + public function getTradeFawn() + { + return $this->container['trade_fawn']; + } + + /** + * Sets trade_fawn + * + * @param \OpenAPI\Client\Model\PostDeerRequestDeersInnerClassesTradeFawn|null $trade_fawn trade_fawn + * + * @return self + */ + public function setTradeFawn($trade_fawn) + { + if (is_null($trade_fawn)) { + throw new \InvalidArgumentException('non-nullable trade_fawn cannot be null'); + } + $this->container['trade_fawn'] = $trade_fawn; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBreedingDoes.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBreedingDoes.php new file mode 100644 index 00000000..a51a0471 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBreedingDoes.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesBreedingDoes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_breedingDoes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBucks.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBucks.php new file mode 100644 index 00000000..29718fb1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesBucks.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesBucks implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_bucks'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesFawn.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesFawn.php new file mode 100644 index 00000000..11873b2a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesFawn.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesFawn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_fawn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesOtherDoes.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesOtherDoes.php new file mode 100644 index 00000000..f0758ef4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesOtherDoes.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesOtherDoes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_otherDoes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeBucks.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeBucks.php new file mode 100644 index 00000000..fe435a19 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeBucks.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesTradeBucks implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_tradeBucks'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeDoes.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeDoes.php new file mode 100644 index 00000000..cafcd335 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeDoes.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesTradeDoes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_tradeDoes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeFawn.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeFawn.php new file mode 100644 index 00000000..5a9c6492 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeFawn.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesTradeFawn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_tradeFawn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeOtherDoes.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeOtherDoes.php new file mode 100644 index 00000000..fa492bcc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerClassesTradeOtherDoes.php @@ -0,0 +1,633 @@ + + */ +class PostDeerRequestDeersInnerClassesTradeOtherDoes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_classes_tradeOtherDoes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerDoesFawning.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerDoesFawning.php new file mode 100644 index 00000000..87f9843b --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerDoesFawning.php @@ -0,0 +1,525 @@ + + */ +class PostDeerRequestDeersInnerDoesFawning implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_doesFawning'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => 'float', + 'summer' => 'float', + 'autumn' => 'float', + 'winter' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerSeasonalFawning.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerSeasonalFawning.php new file mode 100644 index 00000000..400e142a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestDeersInnerSeasonalFawning.php @@ -0,0 +1,525 @@ + + */ +class PostDeerRequestDeersInnerSeasonalFawning implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_deers_inner_seasonalFawning'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => 'float', + 'summer' => 'float', + 'autumn' => 'float', + 'winter' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostDeerRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostDeerRequestVegetationInner.php new file mode 100644 index 00000000..2d77f9ca --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostDeerRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostDeerRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_deer_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'deer_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'deer_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'deer_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'deer_proportion' => 'deerProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'deer_proportion' => 'setDeerProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'deer_proportion' => 'getDeerProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('deer_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['deer_proportion'] === null) { + $invalidProperties[] = "'deer_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets deer_proportion + * + * @return float[] + */ + public function getDeerProportion() + { + return $this->container['deer_proportion']; + } + + /** + * Sets deer_proportion + * + * @param float[] $deer_proportion The proportion of the sequestration that is allocated to deer + * + * @return self + */ + public function setDeerProportion($deer_proportion) + { + if (is_null($deer_proportion)) { + throw new \InvalidArgumentException('non-nullable deer_proportion cannot be null'); + } + $this->container['deer_proportion'] = $deer_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200Response.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200Response.php new file mode 100644 index 00000000..7edc17cf --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200Response.php @@ -0,0 +1,636 @@ + + */ +class PostFeedlot200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostFeedlot200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostFeedlot200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet', + 'intensities' => '\OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInner.php new file mode 100644 index 00000000..2f2038f9 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInner.php @@ -0,0 +1,635 @@ + + */ +class PostFeedlot200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostFeedlot200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostFeedlot200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet', + 'intensities' => '\OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostFeedlot200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..c6b9a5a7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostFeedlot200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'liveweight_produced_kg' => 'float', + 'beef_including_sequestration' => 'float', + 'beef_excluding_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'liveweight_produced_kg' => null, + 'beef_including_sequestration' => null, + 'beef_excluding_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'liveweight_produced_kg' => false, + 'beef_including_sequestration' => false, + 'beef_excluding_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'liveweight_produced_kg' => 'liveweightProducedKg', + 'beef_including_sequestration' => 'beefIncludingSequestration', + 'beef_excluding_sequestration' => 'beefExcludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'liveweight_produced_kg' => 'setLiveweightProducedKg', + 'beef_including_sequestration' => 'setBeefIncludingSequestration', + 'beef_excluding_sequestration' => 'setBeefExcludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'liveweight_produced_kg' => 'getLiveweightProducedKg', + 'beef_including_sequestration' => 'getBeefIncludingSequestration', + 'beef_excluding_sequestration' => 'getBeefExcludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('liveweight_produced_kg', $data ?? [], null); + $this->setIfExists('beef_including_sequestration', $data ?? [], null); + $this->setIfExists('beef_excluding_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['liveweight_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_produced_kg' can't be null"; + } + if ($this->container['beef_including_sequestration'] === null) { + $invalidProperties[] = "'beef_including_sequestration' can't be null"; + } + if ($this->container['beef_excluding_sequestration'] === null) { + $invalidProperties[] = "'beef_excluding_sequestration' 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 liveweight_produced_kg + * + * @return float + */ + public function getLiveweightProducedKg() + { + return $this->container['liveweight_produced_kg']; + } + + /** + * Sets liveweight_produced_kg + * + * @param float $liveweight_produced_kg Amount of meat produced in kg liveweight + * + * @return self + */ + public function setLiveweightProducedKg($liveweight_produced_kg) + { + if (is_null($liveweight_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_produced_kg cannot be null'); + } + $this->container['liveweight_produced_kg'] = $liveweight_produced_kg; + + return $this; + } + + /** + * Gets beef_including_sequestration + * + * @return float + */ + public function getBeefIncludingSequestration() + { + return $this->container['beef_including_sequestration']; + } + + /** + * Sets beef_including_sequestration + * + * @param float $beef_including_sequestration Beef including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefIncludingSequestration($beef_including_sequestration) + { + if (is_null($beef_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_including_sequestration cannot be null'); + } + $this->container['beef_including_sequestration'] = $beef_including_sequestration; + + return $this; + } + + /** + * Gets beef_excluding_sequestration + * + * @return float + */ + public function getBeefExcludingSequestration() + { + return $this->container['beef_excluding_sequestration']; + } + + /** + * Sets beef_excluding_sequestration + * + * @param float $beef_excluding_sequestration Beef excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefExcludingSequestration($beef_excluding_sequestration) + { + if (is_null($beef_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_excluding_sequestration cannot be null'); + } + $this->container['beef_excluding_sequestration'] = $beef_excluding_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerNet.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerNet.php new file mode 100644 index 00000000..8b4fd6fa --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseIntermediateInnerNet.php @@ -0,0 +1,414 @@ + + */ +class PostFeedlot200ResponseIntermediateInnerNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response_intermediate_inner_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope1.php new file mode 100644 index 00000000..5c07ea29 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope1.php @@ -0,0 +1,1043 @@ + + */ +class PostFeedlot200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'transport_co2' => 'float', + 'transport_ch4' => 'float', + 'transport_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'manure_direct_n2_o' => 'float', + 'manure_indirect_n2_o' => 'float', + 'manure_management_ch4' => 'float', + 'manure_applied_to_soil_n2_o' => 'float', + 'enteric_ch4' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'transport_co2' => null, + 'transport_ch4' => null, + 'transport_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'atmospheric_deposition_n2_o' => null, + 'manure_direct_n2_o' => null, + 'manure_indirect_n2_o' => null, + 'manure_management_ch4' => null, + 'manure_applied_to_soil_n2_o' => null, + 'enteric_ch4' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'transport_co2' => false, + 'transport_ch4' => false, + 'transport_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'atmospheric_deposition_n2_o' => false, + 'manure_direct_n2_o' => false, + 'manure_indirect_n2_o' => false, + 'manure_management_ch4' => false, + 'manure_applied_to_soil_n2_o' => false, + 'enteric_ch4' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'transport_co2' => 'transportCO2', + 'transport_ch4' => 'transportCH4', + 'transport_n2_o' => 'transportN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'manure_direct_n2_o' => 'manureDirectN2O', + 'manure_indirect_n2_o' => 'manureIndirectN2O', + 'manure_management_ch4' => 'manureManagementCH4', + 'manure_applied_to_soil_n2_o' => 'manureAppliedToSoilN2O', + 'enteric_ch4' => 'entericCH4', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'transport_co2' => 'setTransportCo2', + 'transport_ch4' => 'setTransportCh4', + 'transport_n2_o' => 'setTransportN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'manure_direct_n2_o' => 'setManureDirectN2O', + 'manure_indirect_n2_o' => 'setManureIndirectN2O', + 'manure_management_ch4' => 'setManureManagementCh4', + 'manure_applied_to_soil_n2_o' => 'setManureAppliedToSoilN2O', + 'enteric_ch4' => 'setEntericCh4', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'transport_co2' => 'getTransportCo2', + 'transport_ch4' => 'getTransportCh4', + 'transport_n2_o' => 'getTransportN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'manure_direct_n2_o' => 'getManureDirectN2O', + 'manure_indirect_n2_o' => 'getManureIndirectN2O', + 'manure_management_ch4' => 'getManureManagementCh4', + 'manure_applied_to_soil_n2_o' => 'getManureAppliedToSoilN2O', + 'enteric_ch4' => 'getEntericCh4', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('transport_co2', $data ?? [], null); + $this->setIfExists('transport_ch4', $data ?? [], null); + $this->setIfExists('transport_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('manure_direct_n2_o', $data ?? [], null); + $this->setIfExists('manure_indirect_n2_o', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('manure_applied_to_soil_n2_o', $data ?? [], null); + $this->setIfExists('enteric_ch4', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['transport_co2'] === null) { + $invalidProperties[] = "'transport_co2' can't be null"; + } + if ($this->container['transport_ch4'] === null) { + $invalidProperties[] = "'transport_ch4' can't be null"; + } + if ($this->container['transport_n2_o'] === null) { + $invalidProperties[] = "'transport_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['manure_direct_n2_o'] === null) { + $invalidProperties[] = "'manure_direct_n2_o' can't be null"; + } + if ($this->container['manure_indirect_n2_o'] === null) { + $invalidProperties[] = "'manure_indirect_n2_o' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['manure_applied_to_soil_n2_o'] === null) { + $invalidProperties[] = "'manure_applied_to_soil_n2_o' can't be null"; + } + if ($this->container['enteric_ch4'] === null) { + $invalidProperties[] = "'enteric_ch4' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets transport_co2 + * + * @return float + */ + public function getTransportCo2() + { + return $this->container['transport_co2']; + } + + /** + * Sets transport_co2 + * + * @param float $transport_co2 CO2 emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportCo2($transport_co2) + { + if (is_null($transport_co2)) { + throw new \InvalidArgumentException('non-nullable transport_co2 cannot be null'); + } + $this->container['transport_co2'] = $transport_co2; + + return $this; + } + + /** + * Gets transport_ch4 + * + * @return float + */ + public function getTransportCh4() + { + return $this->container['transport_ch4']; + } + + /** + * Sets transport_ch4 + * + * @param float $transport_ch4 CH4 emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportCh4($transport_ch4) + { + if (is_null($transport_ch4)) { + throw new \InvalidArgumentException('non-nullable transport_ch4 cannot be null'); + } + $this->container['transport_ch4'] = $transport_ch4; + + return $this; + } + + /** + * Gets transport_n2_o + * + * @return float + */ + public function getTransportN2O() + { + return $this->container['transport_n2_o']; + } + + /** + * Sets transport_n2_o + * + * @param float $transport_n2_o N2O emissions from transport, in tonnes-CO2e + * + * @return self + */ + public function setTransportN2O($transport_n2_o) + { + if (is_null($transport_n2_o)) { + throw new \InvalidArgumentException('non-nullable transport_n2_o cannot be null'); + } + $this->container['transport_n2_o'] = $transport_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets manure_direct_n2_o + * + * @return float + */ + public function getManureDirectN2O() + { + return $this->container['manure_direct_n2_o']; + } + + /** + * Sets manure_direct_n2_o + * + * @param float $manure_direct_n2_o CH4 emissions from manure management (direct), in tonnes-CO2e + * + * @return self + */ + public function setManureDirectN2O($manure_direct_n2_o) + { + if (is_null($manure_direct_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_direct_n2_o cannot be null'); + } + $this->container['manure_direct_n2_o'] = $manure_direct_n2_o; + + return $this; + } + + /** + * Gets manure_indirect_n2_o + * + * @return float + */ + public function getManureIndirectN2O() + { + return $this->container['manure_indirect_n2_o']; + } + + /** + * Sets manure_indirect_n2_o + * + * @param float $manure_indirect_n2_o CH4 emissions from manure management (indirect), in tonnes-CO2e + * + * @return self + */ + public function setManureIndirectN2O($manure_indirect_n2_o) + { + if (is_null($manure_indirect_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_indirect_n2_o cannot be null'); + } + $this->container['manure_indirect_n2_o'] = $manure_indirect_n2_o; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets manure_applied_to_soil_n2_o + * + * @return float + */ + public function getManureAppliedToSoilN2O() + { + return $this->container['manure_applied_to_soil_n2_o']; + } + + /** + * Sets manure_applied_to_soil_n2_o + * + * @param float $manure_applied_to_soil_n2_o CH4 emissions from manure applied to soil, in tonnes-CO2e + * + * @return self + */ + public function setManureAppliedToSoilN2O($manure_applied_to_soil_n2_o) + { + if (is_null($manure_applied_to_soil_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_applied_to_soil_n2_o cannot be null'); + } + $this->container['manure_applied_to_soil_n2_o'] = $manure_applied_to_soil_n2_o; + + return $this; + } + + /** + * Gets enteric_ch4 + * + * @return float + */ + public function getEntericCh4() + { + return $this->container['enteric_ch4']; + } + + /** + * Sets enteric_ch4 + * + * @param float $enteric_ch4 CH4 emissions from enteric fermentation, in tonnes-CO2e + * + * @return self + */ + public function setEntericCh4($enteric_ch4) + { + if (is_null($enteric_ch4)) { + throw new \InvalidArgumentException('non-nullable enteric_ch4 cannot be null'); + } + $this->container['enteric_ch4'] = $enteric_ch4; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope3.php new file mode 100644 index 00000000..2b9e6f03 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlot200ResponseScope3.php @@ -0,0 +1,673 @@ + + */ +class PostFeedlot200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'feed' => 'float', + 'purchase_livestock' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'feed' => null, + 'purchase_livestock' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => false, + 'feed' => false, + 'purchase_livestock' => 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 = [ + 'fertiliser' => 'fertiliser', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'feed' => 'feed', + 'purchase_livestock' => 'purchaseLivestock', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'feed' => 'setFeed', + 'purchase_livestock' => 'setPurchaseLivestock', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + 'feed' => 'getFeed', + 'purchase_livestock' => 'getPurchaseLivestock', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $data ?? [], null); + $this->setIfExists('feed', $data ?? [], null); + $this->setIfExists('purchase_livestock', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['feed'] === null) { + $invalidProperties[] = "'feed' can't be null"; + } + if ($this->container['purchase_livestock'] === null) { + $invalidProperties[] = "'purchase_livestock' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets feed + * + * @return float + */ + public function getFeed() + { + return $this->container['feed']; + } + + /** + * Sets feed + * + * @param float $feed Emissions from feed, in tonnes-CO2e + * + * @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 purchase_livestock + * + * @return float + */ + public function getPurchaseLivestock() + { + return $this->container['purchase_livestock']; + } + + /** + * Sets purchase_livestock + * + * @param float $purchase_livestock Emissions from purchased livestock, in tonnes-CO2e + * + * @return self + */ + public function setPurchaseLivestock($purchase_livestock) + { + if (is_null($purchase_livestock)) { + throw new \InvalidArgumentException('non-nullable purchase_livestock cannot be null'); + } + $this->container['purchase_livestock'] = $purchase_livestock; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequest.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequest.php new file mode 100644 index 00000000..a8dfdb6d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequest.php @@ -0,0 +1,536 @@ + + */ +class PostFeedlotRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'feedlots' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostFeedlotRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'feedlots' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'feedlots' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'feedlots' => 'feedlots', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'feedlots' => 'setFeedlots', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'feedlots' => 'getFeedlots', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('feedlots', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['feedlots'] === null) { + $invalidProperties[] = "'feedlots' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets feedlots + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInner[] + */ + public function getFeedlots() + { + return $this->container['feedlots']; + } + + /** + * Sets feedlots + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInner[] $feedlots feedlots + * + * @return self + */ + public function setFeedlots($feedlots) + { + if (is_null($feedlots)) { + throw new \InvalidArgumentException('non-nullable feedlots cannot be null'); + } + $this->container['feedlots'] = $feedlots; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInner.php new file mode 100644 index 00000000..bb3cb1d2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInner.php @@ -0,0 +1,1275 @@ + + */ +class PostFeedlotRequestFeedlotsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'system' => 'string', + 'groups' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInner[]', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'purchases' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchases', + 'sales' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSales', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'cottonseed_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'distance_cattle_transported' => 'float', + 'truck_type' => 'string', + 'limestone' => 'float', + 'limestone_fraction' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'system' => null, + 'groups' => null, + 'fertiliser' => null, + 'purchases' => null, + 'sales' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'cottonseed_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'distance_cattle_transported' => null, + 'truck_type' => null, + 'limestone' => null, + 'limestone_fraction' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'system' => false, + 'groups' => false, + 'fertiliser' => false, + 'purchases' => false, + 'sales' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'cottonseed_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'distance_cattle_transported' => false, + 'truck_type' => false, + 'limestone' => false, + 'limestone_fraction' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'system' => 'system', + 'groups' => 'groups', + 'fertiliser' => 'fertiliser', + 'purchases' => 'purchases', + 'sales' => 'sales', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'cottonseed_feed' => 'cottonseedFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'distance_cattle_transported' => 'distanceCattleTransported', + 'truck_type' => 'truckType', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'system' => 'setSystem', + 'groups' => 'setGroups', + 'fertiliser' => 'setFertiliser', + 'purchases' => 'setPurchases', + 'sales' => 'setSales', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'cottonseed_feed' => 'setCottonseedFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'distance_cattle_transported' => 'setDistanceCattleTransported', + 'truck_type' => 'setTruckType', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'system' => 'getSystem', + 'groups' => 'getGroups', + 'fertiliser' => 'getFertiliser', + 'purchases' => 'getPurchases', + 'sales' => 'getSales', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'cottonseed_feed' => 'getCottonseedFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'distance_cattle_transported' => 'getDistanceCattleTransported', + 'truck_type' => 'getTruckType', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const SYSTEM_DRYLOT = 'Drylot'; + public const SYSTEM_SOLID_STORAGE = 'Solid Storage'; + public const SYSTEM_COMPOSTING = 'Composting'; + public const SYSTEM_UNCOVERED_ANAEROBIC_LAGOON = 'Uncovered anaerobic lagoon'; + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + public const TRUCK_TYPE__4_DECK_TRAILER = '4 Deck Trailer'; + public const TRUCK_TYPE__6_DECK_TRAILER = '6 Deck Trailer'; + public const TRUCK_TYPE_B_DOUBLE = 'B-Double'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getSystemAllowableValues() + { + return [ + self::SYSTEM_DRYLOT, + self::SYSTEM_SOLID_STORAGE, + self::SYSTEM_COMPOSTING, + self::SYSTEM_UNCOVERED_ANAEROBIC_LAGOON, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTruckTypeAllowableValues() + { + return [ + self::TRUCK_TYPE__4_DECK_TRAILER, + self::TRUCK_TYPE__6_DECK_TRAILER, + self::TRUCK_TYPE_B_DOUBLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('system', $data ?? [], null); + $this->setIfExists('groups', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('sales', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('cottonseed_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('distance_cattle_transported', $data ?? [], null); + $this->setIfExists('truck_type', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['system'] === null) { + $invalidProperties[] = "'system' can't be null"; + } + $allowedValues = $this->getSystemAllowableValues(); + if (!is_null($this->container['system']) && !in_array($this->container['system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'system', must be one of '%s'", + $this->container['system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['groups'] === null) { + $invalidProperties[] = "'groups' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['purchases'] === null) { + $invalidProperties[] = "'purchases' can't be null"; + } + if ($this->container['sales'] === null) { + $invalidProperties[] = "'sales' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['cottonseed_feed'] === null) { + $invalidProperties[] = "'cottonseed_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['distance_cattle_transported'] === null) { + $invalidProperties[] = "'distance_cattle_transported' can't be null"; + } + if ($this->container['truck_type'] === null) { + $invalidProperties[] = "'truck_type' can't be null"; + } + $allowedValues = $this->getTruckTypeAllowableValues(); + if (!is_null($this->container['truck_type']) && !in_array($this->container['truck_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'truck_type', must be one of '%s'", + $this->container['truck_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for the feedlot enterprise + * + * @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 system + * + * @return string + */ + public function getSystem() + { + return $this->container['system']; + } + + /** + * Sets system + * + * @param string $system Type of feedlot/production system + * + * @return self + */ + public function setSystem($system) + { + if (is_null($system)) { + throw new \InvalidArgumentException('non-nullable system cannot be null'); + } + $allowedValues = $this->getSystemAllowableValues(); + if (!in_array($system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'system', must be one of '%s'", + $system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['system'] = $system; + + return $this; + } + + /** + * Gets groups + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInner[] + */ + public function getGroups() + { + return $this->container['groups']; + } + + /** + * Sets groups + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInner[] $groups groups + * + * @return self + */ + public function setGroups($groups) + { + if (is_null($groups)) { + throw new \InvalidArgumentException('non-nullable groups cannot be null'); + } + $this->container['groups'] = $groups; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchases + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchases $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets sales + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSales + */ + public function getSales() + { + return $this->container['sales']; + } + + /** + * Sets sales + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSales $sales sales + * + * @return self + */ + public function setSales($sales) + { + if (is_null($sales)) { + throw new \InvalidArgumentException('non-nullable sales cannot be null'); + } + $this->container['sales'] = $sales; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostFeedlotRequestFeedlotsInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostFeedlotRequestFeedlotsInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets cottonseed_feed + * + * @return float + */ + public function getCottonseedFeed() + { + return $this->container['cottonseed_feed']; + } + + /** + * Sets cottonseed_feed + * + * @param float $cottonseed_feed Cotton seed purchased for cattle feed in tonnes + * + * @return self + */ + public function setCottonseedFeed($cottonseed_feed) + { + if (is_null($cottonseed_feed)) { + throw new \InvalidArgumentException('non-nullable cottonseed_feed cannot be null'); + } + $this->container['cottonseed_feed'] = $cottonseed_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets distance_cattle_transported + * + * @return float + */ + public function getDistanceCattleTransported() + { + return $this->container['distance_cattle_transported']; + } + + /** + * Sets distance_cattle_transported + * + * @param float $distance_cattle_transported Distance cattle are transported to farm, in km (kilometres) + * + * @return self + */ + public function setDistanceCattleTransported($distance_cattle_transported) + { + if (is_null($distance_cattle_transported)) { + throw new \InvalidArgumentException('non-nullable distance_cattle_transported cannot be null'); + } + $this->container['distance_cattle_transported'] = $distance_cattle_transported; + + return $this; + } + + /** + * Gets truck_type + * + * @return string + */ + public function getTruckType() + { + return $this->container['truck_type']; + } + + /** + * Sets truck_type + * + * @param string $truck_type Type of truck used for cattle transport + * + * @return self + */ + public function setTruckType($truck_type) + { + if (is_null($truck_type)) { + throw new \InvalidArgumentException('non-nullable truck_type cannot be null'); + } + $allowedValues = $this->getTruckTypeAllowableValues(); + if (!in_array($truck_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'truck_type', must be one of '%s'", + $truck_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['truck_type'] = $truck_type; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInner.php new file mode 100644 index 00000000..763e7d53 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInner.php @@ -0,0 +1,413 @@ + + */ +class PostFeedlotRequestFeedlotsInnerGroupsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_groups_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'stays' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'stays' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'stays' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'stays' => 'stays' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'stays' => 'setStays' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'stays' => 'getStays' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('stays', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['stays'] === null) { + $invalidProperties[] = "'stays' 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 stays + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner[] + */ + public function getStays() + { + return $this->container['stays']; + } + + /** + * Sets stays + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner[] $stays stays + * + * @return self + */ + public function setStays($stays) + { + if (is_null($stays)) { + throw new \InvalidArgumentException('non-nullable stays cannot be null'); + } + $this->container['stays'] = $stays; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.php new file mode 100644 index 00000000..f181780c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.php @@ -0,0 +1,710 @@ + + */ +class PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_groups_inner_stays_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'livestock' => 'float', + 'stay_average_duration' => 'float', + 'liveweight' => 'float', + 'dry_matter_digestibility' => 'float', + 'crude_protein' => 'float', + 'nitrogen_retention' => 'float', + 'daily_intake' => 'float', + 'ndf' => 'float', + 'ether_extract' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'livestock' => null, + 'stay_average_duration' => null, + 'liveweight' => null, + 'dry_matter_digestibility' => null, + 'crude_protein' => null, + 'nitrogen_retention' => null, + 'daily_intake' => null, + 'ndf' => null, + 'ether_extract' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'livestock' => false, + 'stay_average_duration' => false, + 'liveweight' => false, + 'dry_matter_digestibility' => false, + 'crude_protein' => false, + 'nitrogen_retention' => false, + 'daily_intake' => false, + 'ndf' => false, + 'ether_extract' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'livestock' => 'livestock', + 'stay_average_duration' => 'stayAverageDuration', + 'liveweight' => 'liveweight', + 'dry_matter_digestibility' => 'dryMatterDigestibility', + 'crude_protein' => 'crudeProtein', + 'nitrogen_retention' => 'nitrogenRetention', + 'daily_intake' => 'dailyIntake', + 'ndf' => 'ndf', + 'ether_extract' => 'etherExtract' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'livestock' => 'setLivestock', + 'stay_average_duration' => 'setStayAverageDuration', + 'liveweight' => 'setLiveweight', + 'dry_matter_digestibility' => 'setDryMatterDigestibility', + 'crude_protein' => 'setCrudeProtein', + 'nitrogen_retention' => 'setNitrogenRetention', + 'daily_intake' => 'setDailyIntake', + 'ndf' => 'setNdf', + 'ether_extract' => 'setEtherExtract' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'livestock' => 'getLivestock', + 'stay_average_duration' => 'getStayAverageDuration', + 'liveweight' => 'getLiveweight', + 'dry_matter_digestibility' => 'getDryMatterDigestibility', + 'crude_protein' => 'getCrudeProtein', + 'nitrogen_retention' => 'getNitrogenRetention', + 'daily_intake' => 'getDailyIntake', + 'ndf' => 'getNdf', + 'ether_extract' => 'getEtherExtract' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('livestock', $data ?? [], null); + $this->setIfExists('stay_average_duration', $data ?? [], null); + $this->setIfExists('liveweight', $data ?? [], null); + $this->setIfExists('dry_matter_digestibility', $data ?? [], null); + $this->setIfExists('crude_protein', $data ?? [], null); + $this->setIfExists('nitrogen_retention', $data ?? [], null); + $this->setIfExists('daily_intake', $data ?? [], null); + $this->setIfExists('ndf', $data ?? [], null); + $this->setIfExists('ether_extract', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['livestock'] === null) { + $invalidProperties[] = "'livestock' can't be null"; + } + if ($this->container['stay_average_duration'] === null) { + $invalidProperties[] = "'stay_average_duration' can't be null"; + } + if ($this->container['liveweight'] === null) { + $invalidProperties[] = "'liveweight' can't be null"; + } + if ($this->container['dry_matter_digestibility'] === null) { + $invalidProperties[] = "'dry_matter_digestibility' can't be null"; + } + if ($this->container['crude_protein'] === null) { + $invalidProperties[] = "'crude_protein' can't be null"; + } + if ($this->container['nitrogen_retention'] === null) { + $invalidProperties[] = "'nitrogen_retention' can't be null"; + } + if ($this->container['daily_intake'] === null) { + $invalidProperties[] = "'daily_intake' can't be null"; + } + if ($this->container['ndf'] === null) { + $invalidProperties[] = "'ndf' can't be null"; + } + if ($this->container['ether_extract'] === null) { + $invalidProperties[] = "'ether_extract' 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 livestock + * + * @return float + */ + public function getLivestock() + { + return $this->container['livestock']; + } + + /** + * Sets livestock + * + * @param float $livestock Number of animals (head) + * + * @return self + */ + public function setLivestock($livestock) + { + if (is_null($livestock)) { + throw new \InvalidArgumentException('non-nullable livestock cannot be null'); + } + $this->container['livestock'] = $livestock; + + return $this; + } + + /** + * Gets stay_average_duration + * + * @return float + */ + public function getStayAverageDuration() + { + return $this->container['stay_average_duration']; + } + + /** + * Sets stay_average_duration + * + * @param float $stay_average_duration Average stay length in feedlot, in days + * + * @return self + */ + public function setStayAverageDuration($stay_average_duration) + { + if (is_null($stay_average_duration)) { + throw new \InvalidArgumentException('non-nullable stay_average_duration cannot be null'); + } + $this->container['stay_average_duration'] = $stay_average_duration; + + return $this; + } + + /** + * Gets liveweight + * + * @return float + */ + public function getLiveweight() + { + return $this->container['liveweight']; + } + + /** + * Sets liveweight + * + * @param float $liveweight Average liveweight of animals in kg/head (kilogram per head) + * + * @return self + */ + public function setLiveweight($liveweight) + { + if (is_null($liveweight)) { + throw new \InvalidArgumentException('non-nullable liveweight cannot be null'); + } + $this->container['liveweight'] = $liveweight; + + return $this; + } + + /** + * Gets dry_matter_digestibility + * + * @return float + */ + public function getDryMatterDigestibility() + { + return $this->container['dry_matter_digestibility']; + } + + /** + * Sets dry_matter_digestibility + * + * @param float $dry_matter_digestibility Percent dry matter digestibility of the feed eaten, from 0 to 100 + * + * @return self + */ + public function setDryMatterDigestibility($dry_matter_digestibility) + { + if (is_null($dry_matter_digestibility)) { + throw new \InvalidArgumentException('non-nullable dry_matter_digestibility cannot be null'); + } + $this->container['dry_matter_digestibility'] = $dry_matter_digestibility; + + return $this; + } + + /** + * Gets crude_protein + * + * @return float + */ + public function getCrudeProtein() + { + return $this->container['crude_protein']; + } + + /** + * Sets crude_protein + * + * @param float $crude_protein Percent crude protein of the whole diet, from 0 to 100 + * + * @return self + */ + public function setCrudeProtein($crude_protein) + { + if (is_null($crude_protein)) { + throw new \InvalidArgumentException('non-nullable crude_protein cannot be null'); + } + $this->container['crude_protein'] = $crude_protein; + + return $this; + } + + /** + * Gets nitrogen_retention + * + * @return float + */ + public function getNitrogenRetention() + { + return $this->container['nitrogen_retention']; + } + + /** + * Sets nitrogen_retention + * + * @param float $nitrogen_retention Percent nitrogen retention of intake, from 0 to 100 + * + * @return self + */ + public function setNitrogenRetention($nitrogen_retention) + { + if (is_null($nitrogen_retention)) { + throw new \InvalidArgumentException('non-nullable nitrogen_retention cannot be null'); + } + $this->container['nitrogen_retention'] = $nitrogen_retention; + + return $this; + } + + /** + * Gets daily_intake + * + * @return float + */ + public function getDailyIntake() + { + return $this->container['daily_intake']; + } + + /** + * Sets daily_intake + * + * @param float $daily_intake Daily intake of dry matter in kilograms per head per day + * + * @return self + */ + public function setDailyIntake($daily_intake) + { + if (is_null($daily_intake)) { + throw new \InvalidArgumentException('non-nullable daily_intake cannot be null'); + } + $this->container['daily_intake'] = $daily_intake; + + return $this; + } + + /** + * Gets ndf + * + * @return float + */ + public function getNdf() + { + return $this->container['ndf']; + } + + /** + * Sets ndf + * + * @param float $ndf Percent Neutral detergent fibre (NDF) of intake, from 0 to 100 + * + * @return self + */ + public function setNdf($ndf) + { + if (is_null($ndf)) { + throw new \InvalidArgumentException('non-nullable ndf cannot be null'); + } + $this->container['ndf'] = $ndf; + + return $this; + } + + /** + * Gets ether_extract + * + * @return float + */ + public function getEtherExtract() + { + return $this->container['ether_extract']; + } + + /** + * Sets ether_extract + * + * @param float $ether_extract Percent ether extract of intake, from 0 to 100 + * + * @return self + */ + public function setEtherExtract($ether_extract) + { + if (is_null($ether_extract)) { + throw new \InvalidArgumentException('non-nullable ether_extract cannot be null'); + } + $this->container['ether_extract'] = $ether_extract; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchases.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchases.php new file mode 100644 index 00000000..e4966ed0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchases.php @@ -0,0 +1,921 @@ + + */ +class PostFeedlotRequestFeedlotsInnerPurchases implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_purchases'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bulls_gt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'bulls_gt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers_lt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers_lt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers1_to2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers1_to2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'steers_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'cows_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'cows_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers_lt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers_lt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers1_to2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers1_to2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]', + 'heifers_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bulls_gt1' => null, + 'bulls_gt1_traded' => null, + 'steers_lt1' => null, + 'steers_lt1_traded' => null, + 'steers1_to2' => null, + 'steers1_to2_traded' => null, + 'steers_gt2' => null, + 'steers_gt2_traded' => null, + 'cows_gt2' => null, + 'cows_gt2_traded' => null, + 'heifers_lt1' => null, + 'heifers_lt1_traded' => null, + 'heifers1_to2' => null, + 'heifers1_to2_traded' => null, + 'heifers_gt2' => null, + 'heifers_gt2_traded' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bulls_gt1' => false, + 'bulls_gt1_traded' => false, + 'steers_lt1' => false, + 'steers_lt1_traded' => false, + 'steers1_to2' => false, + 'steers1_to2_traded' => false, + 'steers_gt2' => false, + 'steers_gt2_traded' => false, + 'cows_gt2' => false, + 'cows_gt2_traded' => false, + 'heifers_lt1' => false, + 'heifers_lt1_traded' => false, + 'heifers1_to2' => false, + 'heifers1_to2_traded' => false, + 'heifers_gt2' => false, + 'heifers_gt2_traded' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bulls_gt1' => 'bullsGt1', + 'bulls_gt1_traded' => 'bullsGt1Traded', + 'steers_lt1' => 'steersLt1', + 'steers_lt1_traded' => 'steersLt1Traded', + 'steers1_to2' => 'steers1To2', + 'steers1_to2_traded' => 'steers1To2Traded', + 'steers_gt2' => 'steersGt2', + 'steers_gt2_traded' => 'steersGt2Traded', + 'cows_gt2' => 'cowsGt2', + 'cows_gt2_traded' => 'cowsGt2Traded', + 'heifers_lt1' => 'heifersLt1', + 'heifers_lt1_traded' => 'heifersLt1Traded', + 'heifers1_to2' => 'heifers1To2', + 'heifers1_to2_traded' => 'heifers1To2Traded', + 'heifers_gt2' => 'heifersGt2', + 'heifers_gt2_traded' => 'heifersGt2Traded' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bulls_gt1' => 'setBullsGt1', + 'bulls_gt1_traded' => 'setBullsGt1Traded', + 'steers_lt1' => 'setSteersLt1', + 'steers_lt1_traded' => 'setSteersLt1Traded', + 'steers1_to2' => 'setSteers1To2', + 'steers1_to2_traded' => 'setSteers1To2Traded', + 'steers_gt2' => 'setSteersGt2', + 'steers_gt2_traded' => 'setSteersGt2Traded', + 'cows_gt2' => 'setCowsGt2', + 'cows_gt2_traded' => 'setCowsGt2Traded', + 'heifers_lt1' => 'setHeifersLt1', + 'heifers_lt1_traded' => 'setHeifersLt1Traded', + 'heifers1_to2' => 'setHeifers1To2', + 'heifers1_to2_traded' => 'setHeifers1To2Traded', + 'heifers_gt2' => 'setHeifersGt2', + 'heifers_gt2_traded' => 'setHeifersGt2Traded' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bulls_gt1' => 'getBullsGt1', + 'bulls_gt1_traded' => 'getBullsGt1Traded', + 'steers_lt1' => 'getSteersLt1', + 'steers_lt1_traded' => 'getSteersLt1Traded', + 'steers1_to2' => 'getSteers1To2', + 'steers1_to2_traded' => 'getSteers1To2Traded', + 'steers_gt2' => 'getSteersGt2', + 'steers_gt2_traded' => 'getSteersGt2Traded', + 'cows_gt2' => 'getCowsGt2', + 'cows_gt2_traded' => 'getCowsGt2Traded', + 'heifers_lt1' => 'getHeifersLt1', + 'heifers_lt1_traded' => 'getHeifersLt1Traded', + 'heifers1_to2' => 'getHeifers1To2', + 'heifers1_to2_traded' => 'getHeifers1To2Traded', + 'heifers_gt2' => 'getHeifersGt2', + 'heifers_gt2_traded' => 'getHeifersGt2Traded' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bulls_gt1', $data ?? [], null); + $this->setIfExists('bulls_gt1_traded', $data ?? [], null); + $this->setIfExists('steers_lt1', $data ?? [], null); + $this->setIfExists('steers_lt1_traded', $data ?? [], null); + $this->setIfExists('steers1_to2', $data ?? [], null); + $this->setIfExists('steers1_to2_traded', $data ?? [], null); + $this->setIfExists('steers_gt2', $data ?? [], null); + $this->setIfExists('steers_gt2_traded', $data ?? [], null); + $this->setIfExists('cows_gt2', $data ?? [], null); + $this->setIfExists('cows_gt2_traded', $data ?? [], null); + $this->setIfExists('heifers_lt1', $data ?? [], null); + $this->setIfExists('heifers_lt1_traded', $data ?? [], null); + $this->setIfExists('heifers1_to2', $data ?? [], null); + $this->setIfExists('heifers1_to2_traded', $data ?? [], null); + $this->setIfExists('heifers_gt2', $data ?? [], null); + $this->setIfExists('heifers_gt2_traded', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 bulls_gt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getBullsGt1() + { + return $this->container['bulls_gt1']; + } + + /** + * Sets bulls_gt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $bulls_gt1 Livestock purchases for bulls whose age is greater than 1 year old + * + * @return self + */ + public function setBullsGt1($bulls_gt1) + { + if (is_null($bulls_gt1)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1 cannot be null'); + } + $this->container['bulls_gt1'] = $bulls_gt1; + + return $this; + } + + /** + * Gets bulls_gt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getBullsGt1Traded() + { + return $this->container['bulls_gt1_traded']; + } + + /** + * Sets bulls_gt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $bulls_gt1_traded Livestock purchases for traded bulls whose age is greater than 1 year old + * + * @return self + */ + public function setBullsGt1Traded($bulls_gt1_traded) + { + if (is_null($bulls_gt1_traded)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1_traded cannot be null'); + } + $this->container['bulls_gt1_traded'] = $bulls_gt1_traded; + + return $this; + } + + /** + * Gets steers_lt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteersLt1() + { + return $this->container['steers_lt1']; + } + + /** + * Sets steers_lt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers_lt1 Livestock purchases for Steers whose age is less than 1 year old + * + * @return self + */ + public function setSteersLt1($steers_lt1) + { + if (is_null($steers_lt1)) { + throw new \InvalidArgumentException('non-nullable steers_lt1 cannot be null'); + } + $this->container['steers_lt1'] = $steers_lt1; + + return $this; + } + + /** + * Gets steers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteersLt1Traded() + { + return $this->container['steers_lt1_traded']; + } + + /** + * Sets steers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers_lt1_traded Livestock purchases for traded Steers whose age is less than 1 year old + * + * @return self + */ + public function setSteersLt1Traded($steers_lt1_traded) + { + if (is_null($steers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable steers_lt1_traded cannot be null'); + } + $this->container['steers_lt1_traded'] = $steers_lt1_traded; + + return $this; + } + + /** + * Gets steers1_to2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteers1To2() + { + return $this->container['steers1_to2']; + } + + /** + * Sets steers1_to2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers1_to2 Livestock purchases for Steers whose age is between 1 and 2 years old + * + * @return self + */ + public function setSteers1To2($steers1_to2) + { + if (is_null($steers1_to2)) { + throw new \InvalidArgumentException('non-nullable steers1_to2 cannot be null'); + } + $this->container['steers1_to2'] = $steers1_to2; + + return $this; + } + + /** + * Gets steers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteers1To2Traded() + { + return $this->container['steers1_to2_traded']; + } + + /** + * Sets steers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers1_to2_traded Livestock purchases for traded Steers whose age is between 1 and 2 years old + * + * @return self + */ + public function setSteers1To2Traded($steers1_to2_traded) + { + if (is_null($steers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable steers1_to2_traded cannot be null'); + } + $this->container['steers1_to2_traded'] = $steers1_to2_traded; + + return $this; + } + + /** + * Gets steers_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteersGt2() + { + return $this->container['steers_gt2']; + } + + /** + * Sets steers_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers_gt2 Livestock purchases for Steers whose age is greater than 2 years old + * + * @return self + */ + public function setSteersGt2($steers_gt2) + { + if (is_null($steers_gt2)) { + throw new \InvalidArgumentException('non-nullable steers_gt2 cannot be null'); + } + $this->container['steers_gt2'] = $steers_gt2; + + return $this; + } + + /** + * Gets steers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getSteersGt2Traded() + { + return $this->container['steers_gt2_traded']; + } + + /** + * Sets steers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $steers_gt2_traded Livestock purchases for traded Steers whose age is greater than 2 years old + * + * @return self + */ + public function setSteersGt2Traded($steers_gt2_traded) + { + if (is_null($steers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable steers_gt2_traded cannot be null'); + } + $this->container['steers_gt2_traded'] = $steers_gt2_traded; + + return $this; + } + + /** + * Gets cows_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getCowsGt2() + { + return $this->container['cows_gt2']; + } + + /** + * Sets cows_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $cows_gt2 Livestock purchases for Cows whose age is greater than 2 years old + * + * @return self + */ + public function setCowsGt2($cows_gt2) + { + if (is_null($cows_gt2)) { + throw new \InvalidArgumentException('non-nullable cows_gt2 cannot be null'); + } + $this->container['cows_gt2'] = $cows_gt2; + + return $this; + } + + /** + * Gets cows_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getCowsGt2Traded() + { + return $this->container['cows_gt2_traded']; + } + + /** + * Sets cows_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $cows_gt2_traded Livestock purchases for traded Cows whose age is greater than 2 years old + * + * @return self + */ + public function setCowsGt2Traded($cows_gt2_traded) + { + if (is_null($cows_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable cows_gt2_traded cannot be null'); + } + $this->container['cows_gt2_traded'] = $cows_gt2_traded; + + return $this; + } + + /** + * Gets heifers_lt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifersLt1() + { + return $this->container['heifers_lt1']; + } + + /** + * Sets heifers_lt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers_lt1 Livestock purchases for Heifers whose age is less than 1 year old + * + * @return self + */ + public function setHeifersLt1($heifers_lt1) + { + if (is_null($heifers_lt1)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1 cannot be null'); + } + $this->container['heifers_lt1'] = $heifers_lt1; + + return $this; + } + + /** + * Gets heifers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifersLt1Traded() + { + return $this->container['heifers_lt1_traded']; + } + + /** + * Sets heifers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers_lt1_traded Livestock purchases for traded Heifers whose age is less than 1 year old + * + * @return self + */ + public function setHeifersLt1Traded($heifers_lt1_traded) + { + if (is_null($heifers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1_traded cannot be null'); + } + $this->container['heifers_lt1_traded'] = $heifers_lt1_traded; + + return $this; + } + + /** + * Gets heifers1_to2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifers1To2() + { + return $this->container['heifers1_to2']; + } + + /** + * Sets heifers1_to2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers1_to2 Livestock purchases for Heifers whose age is between 1 and 2 years old + * + * @return self + */ + public function setHeifers1To2($heifers1_to2) + { + if (is_null($heifers1_to2)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2 cannot be null'); + } + $this->container['heifers1_to2'] = $heifers1_to2; + + return $this; + } + + /** + * Gets heifers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifers1To2Traded() + { + return $this->container['heifers1_to2_traded']; + } + + /** + * Sets heifers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers1_to2_traded Livestock purchases for traded Heifers whose age is between 1 and 2 years old + * + * @return self + */ + public function setHeifers1To2Traded($heifers1_to2_traded) + { + if (is_null($heifers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2_traded cannot be null'); + } + $this->container['heifers1_to2_traded'] = $heifers1_to2_traded; + + return $this; + } + + /** + * Gets heifers_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifersGt2() + { + return $this->container['heifers_gt2']; + } + + /** + * Sets heifers_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers_gt2 Livestock purchases for Heifers whose age is greater than 2 years old + * + * @return self + */ + public function setHeifersGt2($heifers_gt2) + { + if (is_null($heifers_gt2)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2 cannot be null'); + } + $this->container['heifers_gt2'] = $heifers_gt2; + + return $this; + } + + /** + * Gets heifers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null + */ + public function getHeifersGt2Traded() + { + return $this->container['heifers_gt2_traded']; + } + + /** + * Sets heifers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner[]|null $heifers_gt2_traded Livestock purchases for traded Heifers whose age is greater than 2 years old + * + * @return self + */ + public function setHeifersGt2Traded($heifers_gt2_traded) + { + if (is_null($heifers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2_traded cannot be null'); + } + $this->container['heifers_gt2_traded'] = $heifers_gt2_traded; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.php new file mode 100644 index 00000000..4c6bbb06 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.php @@ -0,0 +1,535 @@ + + */ +class PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_purchases_bullsGt1_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float', + 'purchase_source' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null, + 'purchase_source' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_weight' => false, + 'purchase_source' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight', + 'purchase_source' => 'purchaseSource' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight', + 'purchase_source' => 'setPurchaseSource' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight', + 'purchase_source' => 'getPurchaseSource' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const PURCHASE_SOURCE_NT = 'NT'; + public const PURCHASE_SOURCE_NTH_QLD = 'nth QLD'; + public const PURCHASE_SOURCE_STH_CENTRAL_QLD = 'sth/central QLD'; + public const PURCHASE_SOURCE_NTH_NSW = 'nth NSW'; + public const PURCHASE_SOURCE_STH_NSW_VIC_STH_SA = 'sth NSW/VIC/sth SA'; + public const PURCHASE_SOURCE_NSW_SA_PASTORAL_ZONE = 'NSW/SA pastoral zone'; + public const PURCHASE_SOURCE_SW_WA = 'sw WA'; + public const PURCHASE_SOURCE_WA_PASTORAL = 'WA pastoral'; + public const PURCHASE_SOURCE_TAS = 'TAS'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getPurchaseSourceAllowableValues() + { + return [ + self::PURCHASE_SOURCE_NT, + self::PURCHASE_SOURCE_NTH_QLD, + self::PURCHASE_SOURCE_STH_CENTRAL_QLD, + self::PURCHASE_SOURCE_NTH_NSW, + self::PURCHASE_SOURCE_STH_NSW_VIC_STH_SA, + self::PURCHASE_SOURCE_NSW_SA_PASTORAL_ZONE, + self::PURCHASE_SOURCE_SW_WA, + self::PURCHASE_SOURCE_WA_PASTORAL, + self::PURCHASE_SOURCE_TAS, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_weight', $data ?? [], null); + $this->setIfExists('purchase_source', $data ?? [], 'sth NSW/VIC/sth SA'); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_weight' can't be null"; + } + if ($this->container['purchase_source'] === null) { + $invalidProperties[] = "'purchase_source' can't be null"; + } + $allowedValues = $this->getPurchaseSourceAllowableValues(); + if (!is_null($this->container['purchase_source']) && !in_array($this->container['purchase_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'purchase_source', must be one of '%s'", + $this->container['purchase_source'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + + /** + * Gets purchase_source + * + * @return string + */ + public function getPurchaseSource() + { + return $this->container['purchase_source']; + } + + /** + * Sets purchase_source + * + * @param string $purchase_source Source location of trading cattle purchases + * + * @return self + */ + public function setPurchaseSource($purchase_source) + { + if (is_null($purchase_source)) { + throw new \InvalidArgumentException('non-nullable purchase_source cannot be null'); + } + $allowedValues = $this->getPurchaseSourceAllowableValues(); + if (!in_array($purchase_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'purchase_source', must be one of '%s'", + $purchase_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['purchase_source'] = $purchase_source; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSales.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSales.php new file mode 100644 index 00000000..f0c73e0d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSales.php @@ -0,0 +1,969 @@ + + */ +class PostFeedlotRequestFeedlotsInnerSales implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_sales'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bulls_gt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'bulls_gt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers_lt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers_lt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers1_to2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers1_to2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'steers_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'cows_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'cows_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers_lt1' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers_lt1_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers1_to2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers1_to2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers_gt2' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]', + 'heifers_gt2_traded' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bulls_gt1' => null, + 'bulls_gt1_traded' => null, + 'steers_lt1' => null, + 'steers_lt1_traded' => null, + 'steers1_to2' => null, + 'steers1_to2_traded' => null, + 'steers_gt2' => null, + 'steers_gt2_traded' => null, + 'cows_gt2' => null, + 'cows_gt2_traded' => null, + 'heifers_lt1' => null, + 'heifers_lt1_traded' => null, + 'heifers1_to2' => null, + 'heifers1_to2_traded' => null, + 'heifers_gt2' => null, + 'heifers_gt2_traded' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bulls_gt1' => false, + 'bulls_gt1_traded' => false, + 'steers_lt1' => false, + 'steers_lt1_traded' => false, + 'steers1_to2' => false, + 'steers1_to2_traded' => false, + 'steers_gt2' => false, + 'steers_gt2_traded' => false, + 'cows_gt2' => false, + 'cows_gt2_traded' => false, + 'heifers_lt1' => false, + 'heifers_lt1_traded' => false, + 'heifers1_to2' => false, + 'heifers1_to2_traded' => false, + 'heifers_gt2' => false, + 'heifers_gt2_traded' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bulls_gt1' => 'bullsGt1', + 'bulls_gt1_traded' => 'bullsGt1Traded', + 'steers_lt1' => 'steersLt1', + 'steers_lt1_traded' => 'steersLt1Traded', + 'steers1_to2' => 'steers1To2', + 'steers1_to2_traded' => 'steers1To2Traded', + 'steers_gt2' => 'steersGt2', + 'steers_gt2_traded' => 'steersGt2Traded', + 'cows_gt2' => 'cowsGt2', + 'cows_gt2_traded' => 'cowsGt2Traded', + 'heifers_lt1' => 'heifersLt1', + 'heifers_lt1_traded' => 'heifersLt1Traded', + 'heifers1_to2' => 'heifers1To2', + 'heifers1_to2_traded' => 'heifers1To2Traded', + 'heifers_gt2' => 'heifersGt2', + 'heifers_gt2_traded' => 'heifersGt2Traded' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bulls_gt1' => 'setBullsGt1', + 'bulls_gt1_traded' => 'setBullsGt1Traded', + 'steers_lt1' => 'setSteersLt1', + 'steers_lt1_traded' => 'setSteersLt1Traded', + 'steers1_to2' => 'setSteers1To2', + 'steers1_to2_traded' => 'setSteers1To2Traded', + 'steers_gt2' => 'setSteersGt2', + 'steers_gt2_traded' => 'setSteersGt2Traded', + 'cows_gt2' => 'setCowsGt2', + 'cows_gt2_traded' => 'setCowsGt2Traded', + 'heifers_lt1' => 'setHeifersLt1', + 'heifers_lt1_traded' => 'setHeifersLt1Traded', + 'heifers1_to2' => 'setHeifers1To2', + 'heifers1_to2_traded' => 'setHeifers1To2Traded', + 'heifers_gt2' => 'setHeifersGt2', + 'heifers_gt2_traded' => 'setHeifersGt2Traded' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bulls_gt1' => 'getBullsGt1', + 'bulls_gt1_traded' => 'getBullsGt1Traded', + 'steers_lt1' => 'getSteersLt1', + 'steers_lt1_traded' => 'getSteersLt1Traded', + 'steers1_to2' => 'getSteers1To2', + 'steers1_to2_traded' => 'getSteers1To2Traded', + 'steers_gt2' => 'getSteersGt2', + 'steers_gt2_traded' => 'getSteersGt2Traded', + 'cows_gt2' => 'getCowsGt2', + 'cows_gt2_traded' => 'getCowsGt2Traded', + 'heifers_lt1' => 'getHeifersLt1', + 'heifers_lt1_traded' => 'getHeifersLt1Traded', + 'heifers1_to2' => 'getHeifers1To2', + 'heifers1_to2_traded' => 'getHeifers1To2Traded', + 'heifers_gt2' => 'getHeifersGt2', + 'heifers_gt2_traded' => 'getHeifersGt2Traded' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bulls_gt1', $data ?? [], null); + $this->setIfExists('bulls_gt1_traded', $data ?? [], null); + $this->setIfExists('steers_lt1', $data ?? [], null); + $this->setIfExists('steers_lt1_traded', $data ?? [], null); + $this->setIfExists('steers1_to2', $data ?? [], null); + $this->setIfExists('steers1_to2_traded', $data ?? [], null); + $this->setIfExists('steers_gt2', $data ?? [], null); + $this->setIfExists('steers_gt2_traded', $data ?? [], null); + $this->setIfExists('cows_gt2', $data ?? [], null); + $this->setIfExists('cows_gt2_traded', $data ?? [], null); + $this->setIfExists('heifers_lt1', $data ?? [], null); + $this->setIfExists('heifers_lt1_traded', $data ?? [], null); + $this->setIfExists('heifers1_to2', $data ?? [], null); + $this->setIfExists('heifers1_to2_traded', $data ?? [], null); + $this->setIfExists('heifers_gt2', $data ?? [], null); + $this->setIfExists('heifers_gt2_traded', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['bulls_gt1'] === null) { + $invalidProperties[] = "'bulls_gt1' can't be null"; + } + if ($this->container['bulls_gt1_traded'] === null) { + $invalidProperties[] = "'bulls_gt1_traded' can't be null"; + } + if ($this->container['steers_lt1'] === null) { + $invalidProperties[] = "'steers_lt1' can't be null"; + } + if ($this->container['steers_lt1_traded'] === null) { + $invalidProperties[] = "'steers_lt1_traded' can't be null"; + } + if ($this->container['steers1_to2'] === null) { + $invalidProperties[] = "'steers1_to2' can't be null"; + } + if ($this->container['steers1_to2_traded'] === null) { + $invalidProperties[] = "'steers1_to2_traded' can't be null"; + } + if ($this->container['steers_gt2'] === null) { + $invalidProperties[] = "'steers_gt2' can't be null"; + } + if ($this->container['steers_gt2_traded'] === null) { + $invalidProperties[] = "'steers_gt2_traded' can't be null"; + } + if ($this->container['cows_gt2'] === null) { + $invalidProperties[] = "'cows_gt2' can't be null"; + } + if ($this->container['cows_gt2_traded'] === null) { + $invalidProperties[] = "'cows_gt2_traded' can't be null"; + } + if ($this->container['heifers_lt1'] === null) { + $invalidProperties[] = "'heifers_lt1' can't be null"; + } + if ($this->container['heifers_lt1_traded'] === null) { + $invalidProperties[] = "'heifers_lt1_traded' can't be null"; + } + if ($this->container['heifers1_to2'] === null) { + $invalidProperties[] = "'heifers1_to2' can't be null"; + } + if ($this->container['heifers1_to2_traded'] === null) { + $invalidProperties[] = "'heifers1_to2_traded' can't be null"; + } + if ($this->container['heifers_gt2'] === null) { + $invalidProperties[] = "'heifers_gt2' can't be null"; + } + if ($this->container['heifers_gt2_traded'] === null) { + $invalidProperties[] = "'heifers_gt2_traded' 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 bulls_gt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getBullsGt1() + { + return $this->container['bulls_gt1']; + } + + /** + * Sets bulls_gt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $bulls_gt1 Livestock sales for bulls whose age is greater than 1 year old + * + * @return self + */ + public function setBullsGt1($bulls_gt1) + { + if (is_null($bulls_gt1)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1 cannot be null'); + } + $this->container['bulls_gt1'] = $bulls_gt1; + + return $this; + } + + /** + * Gets bulls_gt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getBullsGt1Traded() + { + return $this->container['bulls_gt1_traded']; + } + + /** + * Sets bulls_gt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $bulls_gt1_traded Livestock sales for traded bulls whose age is greater than 1 year old + * + * @return self + */ + public function setBullsGt1Traded($bulls_gt1_traded) + { + if (is_null($bulls_gt1_traded)) { + throw new \InvalidArgumentException('non-nullable bulls_gt1_traded cannot be null'); + } + $this->container['bulls_gt1_traded'] = $bulls_gt1_traded; + + return $this; + } + + /** + * Gets steers_lt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteersLt1() + { + return $this->container['steers_lt1']; + } + + /** + * Sets steers_lt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers_lt1 Livestock sales for Steers whose age is less than 1 year old + * + * @return self + */ + public function setSteersLt1($steers_lt1) + { + if (is_null($steers_lt1)) { + throw new \InvalidArgumentException('non-nullable steers_lt1 cannot be null'); + } + $this->container['steers_lt1'] = $steers_lt1; + + return $this; + } + + /** + * Gets steers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteersLt1Traded() + { + return $this->container['steers_lt1_traded']; + } + + /** + * Sets steers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers_lt1_traded Livestock sales for traded Steers whose age is less than 1 year old + * + * @return self + */ + public function setSteersLt1Traded($steers_lt1_traded) + { + if (is_null($steers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable steers_lt1_traded cannot be null'); + } + $this->container['steers_lt1_traded'] = $steers_lt1_traded; + + return $this; + } + + /** + * Gets steers1_to2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteers1To2() + { + return $this->container['steers1_to2']; + } + + /** + * Sets steers1_to2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers1_to2 Livestock sales for Steers whose age is between 1 and 2 years old + * + * @return self + */ + public function setSteers1To2($steers1_to2) + { + if (is_null($steers1_to2)) { + throw new \InvalidArgumentException('non-nullable steers1_to2 cannot be null'); + } + $this->container['steers1_to2'] = $steers1_to2; + + return $this; + } + + /** + * Gets steers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteers1To2Traded() + { + return $this->container['steers1_to2_traded']; + } + + /** + * Sets steers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers1_to2_traded Livestock sales for traded Steers whose age is between 1 and 2 years old + * + * @return self + */ + public function setSteers1To2Traded($steers1_to2_traded) + { + if (is_null($steers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable steers1_to2_traded cannot be null'); + } + $this->container['steers1_to2_traded'] = $steers1_to2_traded; + + return $this; + } + + /** + * Gets steers_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteersGt2() + { + return $this->container['steers_gt2']; + } + + /** + * Sets steers_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers_gt2 Livestock sales for Steers whose age is greater than 2 years old + * + * @return self + */ + public function setSteersGt2($steers_gt2) + { + if (is_null($steers_gt2)) { + throw new \InvalidArgumentException('non-nullable steers_gt2 cannot be null'); + } + $this->container['steers_gt2'] = $steers_gt2; + + return $this; + } + + /** + * Gets steers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getSteersGt2Traded() + { + return $this->container['steers_gt2_traded']; + } + + /** + * Sets steers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $steers_gt2_traded Livestock sales for traded Steers whose age is greater than 2 years old + * + * @return self + */ + public function setSteersGt2Traded($steers_gt2_traded) + { + if (is_null($steers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable steers_gt2_traded cannot be null'); + } + $this->container['steers_gt2_traded'] = $steers_gt2_traded; + + return $this; + } + + /** + * Gets cows_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getCowsGt2() + { + return $this->container['cows_gt2']; + } + + /** + * Sets cows_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $cows_gt2 Livestock sales for Cows whose age is greater than 2 years old + * + * @return self + */ + public function setCowsGt2($cows_gt2) + { + if (is_null($cows_gt2)) { + throw new \InvalidArgumentException('non-nullable cows_gt2 cannot be null'); + } + $this->container['cows_gt2'] = $cows_gt2; + + return $this; + } + + /** + * Gets cows_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getCowsGt2Traded() + { + return $this->container['cows_gt2_traded']; + } + + /** + * Sets cows_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $cows_gt2_traded Livestock sales for traded Cows whose age is greater than 2 years old + * + * @return self + */ + public function setCowsGt2Traded($cows_gt2_traded) + { + if (is_null($cows_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable cows_gt2_traded cannot be null'); + } + $this->container['cows_gt2_traded'] = $cows_gt2_traded; + + return $this; + } + + /** + * Gets heifers_lt1 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifersLt1() + { + return $this->container['heifers_lt1']; + } + + /** + * Sets heifers_lt1 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers_lt1 Livestock sales for Heifers whose age is less than 1 year old + * + * @return self + */ + public function setHeifersLt1($heifers_lt1) + { + if (is_null($heifers_lt1)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1 cannot be null'); + } + $this->container['heifers_lt1'] = $heifers_lt1; + + return $this; + } + + /** + * Gets heifers_lt1_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifersLt1Traded() + { + return $this->container['heifers_lt1_traded']; + } + + /** + * Sets heifers_lt1_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers_lt1_traded Livestock sales for traded Heifers whose age is less than 1 year old + * + * @return self + */ + public function setHeifersLt1Traded($heifers_lt1_traded) + { + if (is_null($heifers_lt1_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_lt1_traded cannot be null'); + } + $this->container['heifers_lt1_traded'] = $heifers_lt1_traded; + + return $this; + } + + /** + * Gets heifers1_to2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifers1To2() + { + return $this->container['heifers1_to2']; + } + + /** + * Sets heifers1_to2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers1_to2 Livestock sales for Heifers whose age is between 1 and 2 years old + * + * @return self + */ + public function setHeifers1To2($heifers1_to2) + { + if (is_null($heifers1_to2)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2 cannot be null'); + } + $this->container['heifers1_to2'] = $heifers1_to2; + + return $this; + } + + /** + * Gets heifers1_to2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifers1To2Traded() + { + return $this->container['heifers1_to2_traded']; + } + + /** + * Sets heifers1_to2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers1_to2_traded Livestock sales for traded Heifers whose age is between 1 and 2 years old + * + * @return self + */ + public function setHeifers1To2Traded($heifers1_to2_traded) + { + if (is_null($heifers1_to2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers1_to2_traded cannot be null'); + } + $this->container['heifers1_to2_traded'] = $heifers1_to2_traded; + + return $this; + } + + /** + * Gets heifers_gt2 + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifersGt2() + { + return $this->container['heifers_gt2']; + } + + /** + * Sets heifers_gt2 + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers_gt2 Livestock sales for Heifers whose age is greater than 2 years old + * + * @return self + */ + public function setHeifersGt2($heifers_gt2) + { + if (is_null($heifers_gt2)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2 cannot be null'); + } + $this->container['heifers_gt2'] = $heifers_gt2; + + return $this; + } + + /** + * Gets heifers_gt2_traded + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] + */ + public function getHeifersGt2Traded() + { + return $this->container['heifers_gt2_traded']; + } + + /** + * Sets heifers_gt2_traded + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner[] $heifers_gt2_traded Livestock sales for traded Heifers whose age is greater than 2 years old + * + * @return self + */ + public function setHeifersGt2Traded($heifers_gt2_traded) + { + if (is_null($heifers_gt2_traded)) { + throw new \InvalidArgumentException('non-nullable heifers_gt2_traded cannot be null'); + } + $this->container['heifers_gt2_traded'] = $heifers_gt2_traded; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.php new file mode 100644 index 00000000..aa5738e7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.php @@ -0,0 +1,450 @@ + + */ +class PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_feedlots_inner_sales_bullsGt1_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'sale_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'sale_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'sale_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 = [ + 'head' => 'head', + 'sale_weight' => 'saleWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'sale_weight' => 'setSaleWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'sale_weight' => 'getSaleWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('sale_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals sold (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestVegetationInner.php new file mode 100644 index 00000000..7433b1f1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostFeedlotRequestVegetationInner.php @@ -0,0 +1,450 @@ + + */ +class PostFeedlotRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_feedlot_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'feedlot_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'feedlot_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'feedlot_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'feedlot_proportion' => 'feedlotProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'feedlot_proportion' => 'setFeedlotProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'feedlot_proportion' => 'getFeedlotProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('feedlot_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['feedlot_proportion'] === null) { + $invalidProperties[] = "'feedlot_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets feedlot_proportion + * + * @return float[] + */ + public function getFeedlotProportion() + { + return $this->container['feedlot_proportion']; + } + + /** + * Sets feedlot_proportion + * + * @param float[] $feedlot_proportion feedlot_proportion + * + * @return self + */ + public function setFeedlotProportion($feedlot_proportion) + { + if (is_null($feedlot_proportion)) { + throw new \InvalidArgumentException('non-nullable feedlot_proportion cannot be null'); + } + $this->container['feedlot_proportion'] = $feedlot_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoat200Response.php b/examples/php-api-client/api-client/lib/Model/PostGoat200Response.php new file mode 100644 index 00000000..3583149f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoat200Response.php @@ -0,0 +1,636 @@ + + */ +class PostGoat200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostGoat200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostGoat200ResponseIntensities', + 'intermediate' => '\OpenAPI\Client\Model\PostGoat200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostGoat200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostGoat200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostGoat200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostGoat200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostGoat200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostGoat200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntensities.php new file mode 100644 index 00000000..8378628f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntensities.php @@ -0,0 +1,598 @@ + + */ +class PostGoat200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'amount_meat_produced' => 'float', + 'amount_wool_produced' => 'float', + 'goat_meat_breeding_including_sequestration' => 'float', + 'goat_meat_breeding_excluding_sequestration' => 'float', + 'wool_including_sequestration' => 'float', + 'wool_excluding_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'amount_meat_produced' => null, + 'amount_wool_produced' => null, + 'goat_meat_breeding_including_sequestration' => null, + 'goat_meat_breeding_excluding_sequestration' => null, + 'wool_including_sequestration' => null, + 'wool_excluding_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'amount_meat_produced' => false, + 'amount_wool_produced' => false, + 'goat_meat_breeding_including_sequestration' => false, + 'goat_meat_breeding_excluding_sequestration' => false, + 'wool_including_sequestration' => false, + 'wool_excluding_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'amount_meat_produced' => 'amountMeatProduced', + 'amount_wool_produced' => 'amountWoolProduced', + 'goat_meat_breeding_including_sequestration' => 'goatMeatBreedingIncludingSequestration', + 'goat_meat_breeding_excluding_sequestration' => 'goatMeatBreedingExcludingSequestration', + 'wool_including_sequestration' => 'woolIncludingSequestration', + 'wool_excluding_sequestration' => 'woolExcludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'amount_meat_produced' => 'setAmountMeatProduced', + 'amount_wool_produced' => 'setAmountWoolProduced', + 'goat_meat_breeding_including_sequestration' => 'setGoatMeatBreedingIncludingSequestration', + 'goat_meat_breeding_excluding_sequestration' => 'setGoatMeatBreedingExcludingSequestration', + 'wool_including_sequestration' => 'setWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'setWoolExcludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'amount_meat_produced' => 'getAmountMeatProduced', + 'amount_wool_produced' => 'getAmountWoolProduced', + 'goat_meat_breeding_including_sequestration' => 'getGoatMeatBreedingIncludingSequestration', + 'goat_meat_breeding_excluding_sequestration' => 'getGoatMeatBreedingExcludingSequestration', + 'wool_including_sequestration' => 'getWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'getWoolExcludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('amount_meat_produced', $data ?? [], null); + $this->setIfExists('amount_wool_produced', $data ?? [], null); + $this->setIfExists('goat_meat_breeding_including_sequestration', $data ?? [], null); + $this->setIfExists('goat_meat_breeding_excluding_sequestration', $data ?? [], null); + $this->setIfExists('wool_including_sequestration', $data ?? [], null); + $this->setIfExists('wool_excluding_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['amount_meat_produced'] === null) { + $invalidProperties[] = "'amount_meat_produced' can't be null"; + } + if ($this->container['amount_wool_produced'] === null) { + $invalidProperties[] = "'amount_wool_produced' can't be null"; + } + if ($this->container['goat_meat_breeding_including_sequestration'] === null) { + $invalidProperties[] = "'goat_meat_breeding_including_sequestration' can't be null"; + } + if ($this->container['goat_meat_breeding_excluding_sequestration'] === null) { + $invalidProperties[] = "'goat_meat_breeding_excluding_sequestration' can't be null"; + } + if ($this->container['wool_including_sequestration'] === null) { + $invalidProperties[] = "'wool_including_sequestration' can't be null"; + } + if ($this->container['wool_excluding_sequestration'] === null) { + $invalidProperties[] = "'wool_excluding_sequestration' 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 amount_meat_produced + * + * @return float + */ + public function getAmountMeatProduced() + { + return $this->container['amount_meat_produced']; + } + + /** + * Sets amount_meat_produced + * + * @param float $amount_meat_produced Amount of goat meat produced in kg liveweight + * + * @return self + */ + public function setAmountMeatProduced($amount_meat_produced) + { + if (is_null($amount_meat_produced)) { + throw new \InvalidArgumentException('non-nullable amount_meat_produced cannot be null'); + } + $this->container['amount_meat_produced'] = $amount_meat_produced; + + return $this; + } + + /** + * Gets amount_wool_produced + * + * @return float + */ + public function getAmountWoolProduced() + { + return $this->container['amount_wool_produced']; + } + + /** + * Sets amount_wool_produced + * + * @param float $amount_wool_produced Amount of wool produced in kg greasy + * + * @return self + */ + public function setAmountWoolProduced($amount_wool_produced) + { + if (is_null($amount_wool_produced)) { + throw new \InvalidArgumentException('non-nullable amount_wool_produced cannot be null'); + } + $this->container['amount_wool_produced'] = $amount_wool_produced; + + return $this; + } + + /** + * Gets goat_meat_breeding_including_sequestration + * + * @return float + */ + public function getGoatMeatBreedingIncludingSequestration() + { + return $this->container['goat_meat_breeding_including_sequestration']; + } + + /** + * Sets goat_meat_breeding_including_sequestration + * + * @param float $goat_meat_breeding_including_sequestration Goat meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setGoatMeatBreedingIncludingSequestration($goat_meat_breeding_including_sequestration) + { + if (is_null($goat_meat_breeding_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable goat_meat_breeding_including_sequestration cannot be null'); + } + $this->container['goat_meat_breeding_including_sequestration'] = $goat_meat_breeding_including_sequestration; + + return $this; + } + + /** + * Gets goat_meat_breeding_excluding_sequestration + * + * @return float + */ + public function getGoatMeatBreedingExcludingSequestration() + { + return $this->container['goat_meat_breeding_excluding_sequestration']; + } + + /** + * Sets goat_meat_breeding_excluding_sequestration + * + * @param float $goat_meat_breeding_excluding_sequestration Goat meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setGoatMeatBreedingExcludingSequestration($goat_meat_breeding_excluding_sequestration) + { + if (is_null($goat_meat_breeding_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable goat_meat_breeding_excluding_sequestration cannot be null'); + } + $this->container['goat_meat_breeding_excluding_sequestration'] = $goat_meat_breeding_excluding_sequestration; + + return $this; + } + + /** + * Gets wool_including_sequestration + * + * @return float + */ + public function getWoolIncludingSequestration() + { + return $this->container['wool_including_sequestration']; + } + + /** + * Sets wool_including_sequestration + * + * @param float $wool_including_sequestration Wool production including carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolIncludingSequestration($wool_including_sequestration) + { + if (is_null($wool_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_including_sequestration cannot be null'); + } + $this->container['wool_including_sequestration'] = $wool_including_sequestration; + + return $this; + } + + /** + * Gets wool_excluding_sequestration + * + * @return float + */ + public function getWoolExcludingSequestration() + { + return $this->container['wool_excluding_sequestration']; + } + + /** + * Sets wool_excluding_sequestration + * + * @param float $wool_excluding_sequestration Wool production excluding carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolExcludingSequestration($wool_excluding_sequestration) + { + if (is_null($wool_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_excluding_sequestration cannot be null'); + } + $this->container['wool_excluding_sequestration'] = $wool_excluding_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntermediateInner.php new file mode 100644 index 00000000..f05c1562 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostGoat200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'net' => '\OpenAPI\Client\Model\PostGoat200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostGoat200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostGoat200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostGoat200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostGoat200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostGoat200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseNet.php new file mode 100644 index 00000000..179671d6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoat200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostGoat200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequest.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequest.php new file mode 100644 index 00000000..d231f02b --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequest.php @@ -0,0 +1,573 @@ + + */ +class PostGoatRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'rainfall_above600' => 'bool', + 'goats' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostGoatRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'rainfall_above600' => null, + 'goats' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'rainfall_above600' => false, + 'goats' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'rainfall_above600' => 'rainfallAbove600', + 'goats' => 'goats', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'rainfall_above600' => 'setRainfallAbove600', + 'goats' => 'setGoats', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'rainfall_above600' => 'getRainfallAbove600', + 'goats' => 'getGoats', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('goats', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['goats'] === null) { + $invalidProperties[] = "'goats' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets goats + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInner[] + */ + public function getGoats() + { + return $this->container['goats']; + } + + /** + * Sets goats + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInner[] $goats goats + * + * @return self + */ + public function setGoats($goats) + { + if (is_null($goats)) { + throw new \InvalidArgumentException('non-nullable goats cannot be null'); + } + $this->container['goats'] = $goats; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostGoatRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostGoatRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInner.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInner.php new file mode 100644 index 00000000..7d7e7f20 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInner.php @@ -0,0 +1,1015 @@ + + */ +class PostGoatRequestGoatsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'mineral_supplementation' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'mineral_supplementation' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'mineral_supplementation' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'mineral_supplementation' => 'mineralSupplementation', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'mineral_supplementation' => 'setMineralSupplementation', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'mineral_supplementation' => 'getMineralSupplementation', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('mineral_supplementation', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['mineral_supplementation'] === null) { + $invalidProperties[] = "'mineral_supplementation' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets mineral_supplementation + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation + */ + public function getMineralSupplementation() + { + return $this->container['mineral_supplementation']; + } + + /** + * Sets mineral_supplementation + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation $mineral_supplementation mineral_supplementation + * + * @return self + */ + public function setMineralSupplementation($mineral_supplementation) + { + if (is_null($mineral_supplementation)) { + throw new \InvalidArgumentException('non-nullable mineral_supplementation cannot be null'); + } + $this->container['mineral_supplementation'] = $mineral_supplementation; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostGoatRequestGoatsInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostGoatRequestGoatsInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClasses.php new file mode 100644 index 00000000..a0be7fd6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClasses.php @@ -0,0 +1,821 @@ + + */ +class PostGoatRequestGoatsInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bucks_billy' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBucksBilly', + 'trade_bucks' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBucks', + 'wethers' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesWethers', + 'trade_wethers' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeWethers', + 'maiden_breeding_does_nannies' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies', + 'trade_maiden_breeding_does_nannies' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies', + 'breeding_does_nannies' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBreedingDoesNannies', + 'trade_breeding_does_nannies' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies', + 'other_does_culled_females' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales', + 'trade_other_does_culled_females' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales', + 'kids' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesKids', + 'trade_kids' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeKids', + 'trade_does' => '\OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeDoes' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bucks_billy' => null, + 'trade_bucks' => null, + 'wethers' => null, + 'trade_wethers' => null, + 'maiden_breeding_does_nannies' => null, + 'trade_maiden_breeding_does_nannies' => null, + 'breeding_does_nannies' => null, + 'trade_breeding_does_nannies' => null, + 'other_does_culled_females' => null, + 'trade_other_does_culled_females' => null, + 'kids' => null, + 'trade_kids' => null, + 'trade_does' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bucks_billy' => false, + 'trade_bucks' => false, + 'wethers' => false, + 'trade_wethers' => false, + 'maiden_breeding_does_nannies' => false, + 'trade_maiden_breeding_does_nannies' => false, + 'breeding_does_nannies' => false, + 'trade_breeding_does_nannies' => false, + 'other_does_culled_females' => false, + 'trade_other_does_culled_females' => false, + 'kids' => false, + 'trade_kids' => false, + 'trade_does' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bucks_billy' => 'bucksBilly', + 'trade_bucks' => 'tradeBucks', + 'wethers' => 'wethers', + 'trade_wethers' => 'tradeWethers', + 'maiden_breeding_does_nannies' => 'maidenBreedingDoesNannies', + 'trade_maiden_breeding_does_nannies' => 'tradeMaidenBreedingDoesNannies', + 'breeding_does_nannies' => 'breedingDoesNannies', + 'trade_breeding_does_nannies' => 'tradeBreedingDoesNannies', + 'other_does_culled_females' => 'otherDoesCulledFemales', + 'trade_other_does_culled_females' => 'tradeOtherDoesCulledFemales', + 'kids' => 'kids', + 'trade_kids' => 'tradeKids', + 'trade_does' => 'tradeDoes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bucks_billy' => 'setBucksBilly', + 'trade_bucks' => 'setTradeBucks', + 'wethers' => 'setWethers', + 'trade_wethers' => 'setTradeWethers', + 'maiden_breeding_does_nannies' => 'setMaidenBreedingDoesNannies', + 'trade_maiden_breeding_does_nannies' => 'setTradeMaidenBreedingDoesNannies', + 'breeding_does_nannies' => 'setBreedingDoesNannies', + 'trade_breeding_does_nannies' => 'setTradeBreedingDoesNannies', + 'other_does_culled_females' => 'setOtherDoesCulledFemales', + 'trade_other_does_culled_females' => 'setTradeOtherDoesCulledFemales', + 'kids' => 'setKids', + 'trade_kids' => 'setTradeKids', + 'trade_does' => 'setTradeDoes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bucks_billy' => 'getBucksBilly', + 'trade_bucks' => 'getTradeBucks', + 'wethers' => 'getWethers', + 'trade_wethers' => 'getTradeWethers', + 'maiden_breeding_does_nannies' => 'getMaidenBreedingDoesNannies', + 'trade_maiden_breeding_does_nannies' => 'getTradeMaidenBreedingDoesNannies', + 'breeding_does_nannies' => 'getBreedingDoesNannies', + 'trade_breeding_does_nannies' => 'getTradeBreedingDoesNannies', + 'other_does_culled_females' => 'getOtherDoesCulledFemales', + 'trade_other_does_culled_females' => 'getTradeOtherDoesCulledFemales', + 'kids' => 'getKids', + 'trade_kids' => 'getTradeKids', + 'trade_does' => 'getTradeDoes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('bucks_billy', $data ?? [], null); + $this->setIfExists('trade_bucks', $data ?? [], null); + $this->setIfExists('wethers', $data ?? [], null); + $this->setIfExists('trade_wethers', $data ?? [], null); + $this->setIfExists('maiden_breeding_does_nannies', $data ?? [], null); + $this->setIfExists('trade_maiden_breeding_does_nannies', $data ?? [], null); + $this->setIfExists('breeding_does_nannies', $data ?? [], null); + $this->setIfExists('trade_breeding_does_nannies', $data ?? [], null); + $this->setIfExists('other_does_culled_females', $data ?? [], null); + $this->setIfExists('trade_other_does_culled_females', $data ?? [], null); + $this->setIfExists('kids', $data ?? [], null); + $this->setIfExists('trade_kids', $data ?? [], null); + $this->setIfExists('trade_does', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 bucks_billy + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBucksBilly|null + */ + public function getBucksBilly() + { + return $this->container['bucks_billy']; + } + + /** + * Sets bucks_billy + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBucksBilly|null $bucks_billy bucks_billy + * + * @return self + */ + public function setBucksBilly($bucks_billy) + { + if (is_null($bucks_billy)) { + throw new \InvalidArgumentException('non-nullable bucks_billy cannot be null'); + } + $this->container['bucks_billy'] = $bucks_billy; + + return $this; + } + + /** + * Gets trade_bucks + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBucks|null + */ + public function getTradeBucks() + { + return $this->container['trade_bucks']; + } + + /** + * Sets trade_bucks + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBucks|null $trade_bucks trade_bucks + * + * @return self + */ + public function setTradeBucks($trade_bucks) + { + if (is_null($trade_bucks)) { + throw new \InvalidArgumentException('non-nullable trade_bucks cannot be null'); + } + $this->container['trade_bucks'] = $trade_bucks; + + return $this; + } + + /** + * Gets wethers + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesWethers|null + */ + public function getWethers() + { + return $this->container['wethers']; + } + + /** + * Sets wethers + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesWethers|null $wethers wethers + * + * @return self + */ + public function setWethers($wethers) + { + if (is_null($wethers)) { + throw new \InvalidArgumentException('non-nullable wethers cannot be null'); + } + $this->container['wethers'] = $wethers; + + return $this; + } + + /** + * Gets trade_wethers + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeWethers|null + */ + public function getTradeWethers() + { + return $this->container['trade_wethers']; + } + + /** + * Sets trade_wethers + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeWethers|null $trade_wethers trade_wethers + * + * @return self + */ + public function setTradeWethers($trade_wethers) + { + if (is_null($trade_wethers)) { + throw new \InvalidArgumentException('non-nullable trade_wethers cannot be null'); + } + $this->container['trade_wethers'] = $trade_wethers; + + return $this; + } + + /** + * Gets maiden_breeding_does_nannies + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies|null + */ + public function getMaidenBreedingDoesNannies() + { + return $this->container['maiden_breeding_does_nannies']; + } + + /** + * Sets maiden_breeding_does_nannies + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies|null $maiden_breeding_does_nannies maiden_breeding_does_nannies + * + * @return self + */ + public function setMaidenBreedingDoesNannies($maiden_breeding_does_nannies) + { + if (is_null($maiden_breeding_does_nannies)) { + throw new \InvalidArgumentException('non-nullable maiden_breeding_does_nannies cannot be null'); + } + $this->container['maiden_breeding_does_nannies'] = $maiden_breeding_does_nannies; + + return $this; + } + + /** + * Gets trade_maiden_breeding_does_nannies + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies|null + */ + public function getTradeMaidenBreedingDoesNannies() + { + return $this->container['trade_maiden_breeding_does_nannies']; + } + + /** + * Sets trade_maiden_breeding_does_nannies + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies|null $trade_maiden_breeding_does_nannies trade_maiden_breeding_does_nannies + * + * @return self + */ + public function setTradeMaidenBreedingDoesNannies($trade_maiden_breeding_does_nannies) + { + if (is_null($trade_maiden_breeding_does_nannies)) { + throw new \InvalidArgumentException('non-nullable trade_maiden_breeding_does_nannies cannot be null'); + } + $this->container['trade_maiden_breeding_does_nannies'] = $trade_maiden_breeding_does_nannies; + + return $this; + } + + /** + * Gets breeding_does_nannies + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBreedingDoesNannies|null + */ + public function getBreedingDoesNannies() + { + return $this->container['breeding_does_nannies']; + } + + /** + * Sets breeding_does_nannies + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesBreedingDoesNannies|null $breeding_does_nannies breeding_does_nannies + * + * @return self + */ + public function setBreedingDoesNannies($breeding_does_nannies) + { + if (is_null($breeding_does_nannies)) { + throw new \InvalidArgumentException('non-nullable breeding_does_nannies cannot be null'); + } + $this->container['breeding_does_nannies'] = $breeding_does_nannies; + + return $this; + } + + /** + * Gets trade_breeding_does_nannies + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies|null + */ + public function getTradeBreedingDoesNannies() + { + return $this->container['trade_breeding_does_nannies']; + } + + /** + * Sets trade_breeding_does_nannies + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies|null $trade_breeding_does_nannies trade_breeding_does_nannies + * + * @return self + */ + public function setTradeBreedingDoesNannies($trade_breeding_does_nannies) + { + if (is_null($trade_breeding_does_nannies)) { + throw new \InvalidArgumentException('non-nullable trade_breeding_does_nannies cannot be null'); + } + $this->container['trade_breeding_does_nannies'] = $trade_breeding_does_nannies; + + return $this; + } + + /** + * Gets other_does_culled_females + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales|null + */ + public function getOtherDoesCulledFemales() + { + return $this->container['other_does_culled_females']; + } + + /** + * Sets other_does_culled_females + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales|null $other_does_culled_females other_does_culled_females + * + * @return self + */ + public function setOtherDoesCulledFemales($other_does_culled_females) + { + if (is_null($other_does_culled_females)) { + throw new \InvalidArgumentException('non-nullable other_does_culled_females cannot be null'); + } + $this->container['other_does_culled_females'] = $other_does_culled_females; + + return $this; + } + + /** + * Gets trade_other_does_culled_females + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales|null + */ + public function getTradeOtherDoesCulledFemales() + { + return $this->container['trade_other_does_culled_females']; + } + + /** + * Sets trade_other_does_culled_females + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales|null $trade_other_does_culled_females trade_other_does_culled_females + * + * @return self + */ + public function setTradeOtherDoesCulledFemales($trade_other_does_culled_females) + { + if (is_null($trade_other_does_culled_females)) { + throw new \InvalidArgumentException('non-nullable trade_other_does_culled_females cannot be null'); + } + $this->container['trade_other_does_culled_females'] = $trade_other_does_culled_females; + + return $this; + } + + /** + * Gets kids + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesKids|null + */ + public function getKids() + { + return $this->container['kids']; + } + + /** + * Sets kids + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesKids|null $kids kids + * + * @return self + */ + public function setKids($kids) + { + if (is_null($kids)) { + throw new \InvalidArgumentException('non-nullable kids cannot be null'); + } + $this->container['kids'] = $kids; + + return $this; + } + + /** + * Gets trade_kids + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeKids|null + */ + public function getTradeKids() + { + return $this->container['trade_kids']; + } + + /** + * Sets trade_kids + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeKids|null $trade_kids trade_kids + * + * @return self + */ + public function setTradeKids($trade_kids) + { + if (is_null($trade_kids)) { + throw new \InvalidArgumentException('non-nullable trade_kids cannot be null'); + } + $this->container['trade_kids'] = $trade_kids; + + return $this; + } + + /** + * Gets trade_does + * + * @return \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeDoes|null + * @deprecated + */ + public function getTradeDoes() + { + return $this->container['trade_does']; + } + + /** + * Sets trade_does + * + * @param \OpenAPI\Client\Model\PostGoatRequestGoatsInnerClassesTradeDoes|null $trade_does trade_does + * + * @return self + * @deprecated + */ + public function setTradeDoes($trade_does) + { + if (is_null($trade_does)) { + throw new \InvalidArgumentException('non-nullable trade_does cannot be null'); + } + $this->container['trade_does'] = $trade_does; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.php new file mode 100644 index 00000000..25477e86 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesBreedingDoesNannies implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_breedingDoesNannies'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBucksBilly.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBucksBilly.php new file mode 100644 index 00000000..eac12a68 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesBucksBilly.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesBucksBilly implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_bucksBilly'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesKids.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesKids.php new file mode 100644 index 00000000..76688b2a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesKids.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesKids implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_kids'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.php new file mode 100644 index 00000000..395e9a04 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_maidenBreedingDoesNannies'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.php new file mode 100644 index 00000000..aea95518 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_otherDoesCulledFemales'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.php new file mode 100644 index 00000000..563968aa --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeBreedingDoesNannies'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBucks.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBucks.php new file mode 100644 index 00000000..763bb086 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeBucks.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeBucks implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeBucks'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeDoes.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeDoes.php new file mode 100644 index 00000000..29b8075d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeDoes.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeDoes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeDoes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeKids.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeKids.php new file mode 100644 index 00000000..d5b74bd4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeKids.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeKids implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeKids'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.php new file mode 100644 index 00000000..6e2153f2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeMaidenBreedingDoesNannies'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.php new file mode 100644 index 00000000..b1f1d6c8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeOtherDoesCulledFemales'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeWethers.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeWethers.php new file mode 100644 index 00000000..0e485326 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesTradeWethers.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesTradeWethers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_tradeWethers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesWethers.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesWethers.php new file mode 100644 index 00000000..de0bc28a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestGoatsInnerClassesWethers.php @@ -0,0 +1,816 @@ + + */ +class PostGoatRequestGoatsInnerClassesWethers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_goats_inner_classes_wethers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' 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 autumn + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of goat shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGoatRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostGoatRequestVegetationInner.php new file mode 100644 index 00000000..2d6084e2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGoatRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostGoatRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_goat_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'goat_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'goat_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'goat_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'goat_proportion' => 'goatProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'goat_proportion' => 'setGoatProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'goat_proportion' => 'getGoatProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('goat_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['goat_proportion'] === null) { + $invalidProperties[] = "'goat_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets goat_proportion + * + * @return float[] + */ + public function getGoatProportion() + { + return $this->container['goat_proportion']; + } + + /** + * Sets goat_proportion + * + * @param float[] $goat_proportion The proportion of the sequestration that is allocated to goat + * + * @return self + */ + public function setGoatProportion($goat_proportion) + { + if (is_null($goat_proportion)) { + throw new \InvalidArgumentException('non-nullable goat_proportion cannot be null'); + } + $this->container['goat_proportion'] = $goat_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGrains200Response.php b/examples/php-api-client/api-client/lib/Model/PostGrains200Response.php new file mode 100644 index 00000000..3e0b707f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGrains200Response.php @@ -0,0 +1,673 @@ + + */ +class PostGrains200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_grains_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostGrains200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostCotton200ResponseNet', + 'intensities_with_sequestration' => '\OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration[]', + 'intensities' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities_with_sequestration' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities_with_sequestration' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities_with_sequestration' => 'intensitiesWithSequestration', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities_with_sequestration' => 'setIntensitiesWithSequestration', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities_with_sequestration' => 'getIntensitiesWithSequestration', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities_with_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities_with_sequestration'] === null) { + $invalidProperties[] = "'intensities_with_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities_with_sequestration + * + * @return \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration[] + */ + public function getIntensitiesWithSequestration() + { + return $this->container['intensities_with_sequestration']; + } + + /** + * Sets intensities_with_sequestration + * + * @param \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration[] $intensities_with_sequestration Emissions intensity for each crop (in order), in t-CO2e/t crop + * + * @return self + */ + public function setIntensitiesWithSequestration($intensities_with_sequestration) + { + if (is_null($intensities_with_sequestration)) { + throw new \InvalidArgumentException('non-nullable intensities_with_sequestration cannot be null'); + } + $this->container['intensities_with_sequestration'] = $intensities_with_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return float[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param float[] $intensities Emissions intensity for each crop (in order), in t-CO2e/t crop + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInner.php new file mode 100644 index 00000000..39662504 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostGrains200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_grains_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'intensities_with_sequestration' => '\OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'intensities_with_sequestration' => null, + 'net' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'intensities_with_sequestration' => false, + 'net' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'intensities_with_sequestration' => 'intensitiesWithSequestration', + 'net' => 'net', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'intensities_with_sequestration' => 'setIntensitiesWithSequestration', + 'net' => 'setNet', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'intensities_with_sequestration' => 'getIntensitiesWithSequestration', + 'net' => 'getNet', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('intensities_with_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['intensities_with_sequestration'] === null) { + $invalidProperties[] = "'intensities_with_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets intensities_with_sequestration + * + * @return \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration + */ + public function getIntensitiesWithSequestration() + { + return $this->container['intensities_with_sequestration']; + } + + /** + * Sets intensities_with_sequestration + * + * @param \OpenAPI\Client\Model\PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration $intensities_with_sequestration intensities_with_sequestration + * + * @return self + */ + public function setIntensitiesWithSequestration($intensities_with_sequestration) + { + if (is_null($intensities_with_sequestration)) { + throw new \InvalidArgumentException('non-nullable intensities_with_sequestration cannot be null'); + } + $this->container['intensities_with_sequestration'] = $intensities_with_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.php b/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.php new file mode 100644 index 00000000..0903b7cb --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.php @@ -0,0 +1,487 @@ + + */ +class PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_grains_200_response_intermediate_inner_intensitiesWithSequestration'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'grain_produced_tonnes' => 'float', + 'grains_excluding_sequestration' => 'float', + 'grains_including_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'grain_produced_tonnes' => null, + 'grains_excluding_sequestration' => null, + 'grains_including_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'grain_produced_tonnes' => false, + 'grains_excluding_sequestration' => false, + 'grains_including_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'grain_produced_tonnes' => 'grainProducedTonnes', + 'grains_excluding_sequestration' => 'grainsExcludingSequestration', + 'grains_including_sequestration' => 'grainsIncludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'grain_produced_tonnes' => 'setGrainProducedTonnes', + 'grains_excluding_sequestration' => 'setGrainsExcludingSequestration', + 'grains_including_sequestration' => 'setGrainsIncludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'grain_produced_tonnes' => 'getGrainProducedTonnes', + 'grains_excluding_sequestration' => 'getGrainsExcludingSequestration', + 'grains_including_sequestration' => 'getGrainsIncludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('grain_produced_tonnes', $data ?? [], null); + $this->setIfExists('grains_excluding_sequestration', $data ?? [], null); + $this->setIfExists('grains_including_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['grain_produced_tonnes'] === null) { + $invalidProperties[] = "'grain_produced_tonnes' can't be null"; + } + if ($this->container['grains_excluding_sequestration'] === null) { + $invalidProperties[] = "'grains_excluding_sequestration' can't be null"; + } + if ($this->container['grains_including_sequestration'] === null) { + $invalidProperties[] = "'grains_including_sequestration' 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 grain_produced_tonnes + * + * @return float + */ + public function getGrainProducedTonnes() + { + return $this->container['grain_produced_tonnes']; + } + + /** + * Sets grain_produced_tonnes + * + * @param float $grain_produced_tonnes Grain produced in tonnes + * + * @return self + */ + public function setGrainProducedTonnes($grain_produced_tonnes) + { + if (is_null($grain_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable grain_produced_tonnes cannot be null'); + } + $this->container['grain_produced_tonnes'] = $grain_produced_tonnes; + + return $this; + } + + /** + * Gets grains_excluding_sequestration + * + * @return float + */ + public function getGrainsExcludingSequestration() + { + return $this->container['grains_excluding_sequestration']; + } + + /** + * Sets grains_excluding_sequestration + * + * @param float $grains_excluding_sequestration Grains excluding sequestration, in t-CO2e/t grain + * + * @return self + */ + public function setGrainsExcludingSequestration($grains_excluding_sequestration) + { + if (is_null($grains_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable grains_excluding_sequestration cannot be null'); + } + $this->container['grains_excluding_sequestration'] = $grains_excluding_sequestration; + + return $this; + } + + /** + * Gets grains_including_sequestration + * + * @return float + */ + public function getGrainsIncludingSequestration() + { + return $this->container['grains_including_sequestration']; + } + + /** + * Sets grains_including_sequestration + * + * @param float $grains_including_sequestration Grains including sequestration, in t-CO2e/t grain + * + * @return self + */ + public function setGrainsIncludingSequestration($grains_including_sequestration) + { + if (is_null($grains_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable grains_including_sequestration cannot be null'); + } + $this->container['grains_including_sequestration'] = $grains_including_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGrainsRequest.php b/examples/php-api-client/api-client/lib/Model/PostGrainsRequest.php new file mode 100644 index 00000000..e3f0c25e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGrainsRequest.php @@ -0,0 +1,626 @@ + + */ +class PostGrainsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_grains_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'crops' => '\OpenAPI\Client\Model\PostGrainsRequestCropsInner[]', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'vegetation' => '\OpenAPI\Client\Model\PostCottonRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'crops' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'crops' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'crops' => 'crops', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'crops' => 'setCrops', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'crops' => 'getCrops', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets crops + * + * @return \OpenAPI\Client\Model\PostGrainsRequestCropsInner[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param \OpenAPI\Client\Model\PostGrainsRequestCropsInner[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostGrainsRequest., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostGrainsRequest., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostGrainsRequestCropsInner.php b/examples/php-api-client/api-client/lib/Model/PostGrainsRequestCropsInner.php new file mode 100644 index 00000000..d4e6b2dd --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostGrainsRequestCropsInner.php @@ -0,0 +1,1347 @@ + + */ +class PostGrainsRequestCropsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_grains_request_crops_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'state' => 'string', + 'production_system' => 'string', + 'average_grain_yield' => 'float', + 'area_sown' => 'float', + 'non_urea_nitrogen' => 'float', + 'urea_application' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'rainfall_above600' => 'bool', + 'fraction_of_annual_crop_burnt' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_allocation' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'diesel_use' => 'float', + 'petrol_use' => 'float', + 'lpg' => 'float' + ]; + + /** + * 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, + 'state' => null, + 'production_system' => null, + 'average_grain_yield' => null, + 'area_sown' => null, + 'non_urea_nitrogen' => null, + 'urea_application' => null, + 'urea_ammonium_nitrate' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'rainfall_above600' => null, + 'fraction_of_annual_crop_burnt' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_allocation' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'diesel_use' => null, + 'petrol_use' => null, + 'lpg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'type' => false, + 'state' => false, + 'production_system' => false, + 'average_grain_yield' => false, + 'area_sown' => false, + 'non_urea_nitrogen' => false, + 'urea_application' => false, + 'urea_ammonium_nitrate' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'rainfall_above600' => false, + 'fraction_of_annual_crop_burnt' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_allocation' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'diesel_use' => false, + 'petrol_use' => false, + 'lpg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'production_system' => 'productionSystem', + 'average_grain_yield' => 'averageGrainYield', + 'area_sown' => 'areaSown', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'urea_application' => 'ureaApplication', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'rainfall_above600' => 'rainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'fractionOfAnnualCropBurnt', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_allocation' => 'electricityAllocation', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'diesel_use' => 'dieselUse', + 'petrol_use' => 'petrolUse', + 'lpg' => 'lpg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'state' => 'setState', + 'production_system' => 'setProductionSystem', + 'average_grain_yield' => 'setAverageGrainYield', + 'area_sown' => 'setAreaSown', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'urea_application' => 'setUreaApplication', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'rainfall_above600' => 'setRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'setFractionOfAnnualCropBurnt', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'setElectricityAllocation', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'diesel_use' => 'setDieselUse', + 'petrol_use' => 'setPetrolUse', + 'lpg' => 'setLpg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'state' => 'getState', + 'production_system' => 'getProductionSystem', + 'average_grain_yield' => 'getAverageGrainYield', + 'area_sown' => 'getAreaSown', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'urea_application' => 'getUreaApplication', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'rainfall_above600' => 'getRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'getFractionOfAnnualCropBurnt', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'getElectricityAllocation', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'diesel_use' => 'getDieselUse', + 'petrol_use' => 'getPetrolUse', + 'lpg' => 'getLpg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_WHEAT = 'Wheat'; + public const TYPE_BARLEY = 'Barley'; + public const TYPE_MAIZE = 'Maize'; + public const TYPE_OATS = 'Oats'; + public const TYPE_RICE = 'Rice'; + public const TYPE_SORGHUM = 'Sorghum'; + public const TYPE_TRITICALE = 'Triticale'; + public const TYPE_OTHER_CEREALS = 'Other Cereals'; + public const TYPE_PULSES = 'Pulses'; + public const TYPE_TUBER_AND_ROOTS = 'Tuber and Roots'; + public const TYPE_PEANUTS = 'Peanuts'; + public const TYPE_SUGAR_CANE = 'Sugar Cane'; + public const TYPE_COTTON = 'Cotton'; + public const TYPE_HOPS = 'Hops'; + public const TYPE_OILSEEDS = 'Oilseeds'; + public const TYPE_FORAGE_CROPS = 'Forage Crops'; + public const TYPE_LUCERNE = 'Lucerne'; + public const TYPE_OTHER_LEGUME = 'Other legume'; + public const TYPE_ANNUAL_GRASS = 'Annual grass'; + public const TYPE_GRASS_CLOVER_MIXTURE = 'Grass clover mixture'; + public const TYPE_PERENNIAL_PASTURE = 'Perennial pasture'; + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const PRODUCTION_SYSTEM_NON_IRRIGATED_CROP = 'Non-irrigated crop'; + public const PRODUCTION_SYSTEM_IRRIGATED_CROP = 'Irrigated crop'; + public const PRODUCTION_SYSTEM_SUGAR_CANE = 'Sugar cane'; + public const PRODUCTION_SYSTEM_COTTON = 'Cotton'; + public const PRODUCTION_SYSTEM_HORTICULTURE = 'Horticulture'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_WHEAT, + self::TYPE_BARLEY, + self::TYPE_MAIZE, + self::TYPE_OATS, + self::TYPE_RICE, + self::TYPE_SORGHUM, + self::TYPE_TRITICALE, + self::TYPE_OTHER_CEREALS, + self::TYPE_PULSES, + self::TYPE_TUBER_AND_ROOTS, + self::TYPE_PEANUTS, + self::TYPE_SUGAR_CANE, + self::TYPE_COTTON, + self::TYPE_HOPS, + self::TYPE_OILSEEDS, + self::TYPE_FORAGE_CROPS, + self::TYPE_LUCERNE, + self::TYPE_OTHER_LEGUME, + self::TYPE_ANNUAL_GRASS, + self::TYPE_GRASS_CLOVER_MIXTURE, + self::TYPE_PERENNIAL_PASTURE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductionSystemAllowableValues() + { + return [ + self::PRODUCTION_SYSTEM_NON_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_SUGAR_CANE, + self::PRODUCTION_SYSTEM_COTTON, + self::PRODUCTION_SYSTEM_HORTICULTURE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $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('state', $data ?? [], null); + $this->setIfExists('production_system', $data ?? [], null); + $this->setIfExists('average_grain_yield', $data ?? [], null); + $this->setIfExists('area_sown', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], null); + $this->setIfExists('phosphorus_application', $data ?? [], null); + $this->setIfExists('potassium_application', $data ?? [], null); + $this->setIfExists('sulfur_application', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('fraction_of_annual_crop_burnt', $data ?? [], null); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_allocation', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('diesel_use', $data ?? [], null); + $this->setIfExists('petrol_use', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['production_system'] === null) { + $invalidProperties[] = "'production_system' can't be null"; + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!is_null($this->container['production_system']) && !in_array($this->container['production_system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'production_system', must be one of '%s'", + $this->container['production_system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_grain_yield'] === null) { + $invalidProperties[] = "'average_grain_yield' can't be null"; + } + if ($this->container['area_sown'] === null) { + $invalidProperties[] = "'area_sown' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['fraction_of_annual_crop_burnt'] === null) { + $invalidProperties[] = "'fraction_of_annual_crop_burnt' can't be null"; + } + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_allocation'] === null) { + $invalidProperties[] = "'electricity_allocation' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['diesel_use'] === null) { + $invalidProperties[] = "'diesel_use' can't be null"; + } + if ($this->container['petrol_use'] === null) { + $invalidProperties[] = "'petrol_use' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Crop type. Note that the following crop types are now deprecated, the relevant full calculator should be used instead: 'Cotton', 'Rice', 'Sugar Cane' + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets production_system + * + * @return string + */ + public function getProductionSystem() + { + return $this->container['production_system']; + } + + /** + * Sets production_system + * + * @param string $production_system Production system of this crop. Note that the following production systems are now deprecated, the relevant full calculator should be used instead: 'Cotton', 'Rice', 'Sugar cane' + * + * @return self + */ + public function setProductionSystem($production_system) + { + if (is_null($production_system)) { + throw new \InvalidArgumentException('non-nullable production_system cannot be null'); + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!in_array($production_system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'production_system', must be one of '%s'", + $production_system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['production_system'] = $production_system; + + return $this; + } + + /** + * Gets average_grain_yield + * + * @return float + */ + public function getAverageGrainYield() + { + return $this->container['average_grain_yield']; + } + + /** + * Sets average_grain_yield + * + * @param float $average_grain_yield Average grain yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageGrainYield($average_grain_yield) + { + if (is_null($average_grain_yield)) { + throw new \InvalidArgumentException('non-nullable average_grain_yield cannot be null'); + } + $this->container['average_grain_yield'] = $average_grain_yield; + + return $this; + } + + /** + * Gets area_sown + * + * @return float + */ + public function getAreaSown() + { + return $this->container['area_sown']; + } + + /** + * Sets area_sown + * + * @param float $area_sown Area sown, in ha (hectares) + * + * @return self + */ + public function setAreaSown($area_sown) + { + if (is_null($area_sown)) { + throw new \InvalidArgumentException('non-nullable area_sown cannot be null'); + } + $this->container['area_sown'] = $area_sown; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets fraction_of_annual_crop_burnt + * + * @return float + */ + public function getFractionOfAnnualCropBurnt() + { + return $this->container['fraction_of_annual_crop_burnt']; + } + + /** + * Sets fraction_of_annual_crop_burnt + * + * @param float $fraction_of_annual_crop_burnt Fraction of annual production of crop that is burnt, from 0 to 1 + * + * @return self + */ + public function setFractionOfAnnualCropBurnt($fraction_of_annual_crop_burnt) + { + if (is_null($fraction_of_annual_crop_burnt)) { + throw new \InvalidArgumentException('non-nullable fraction_of_annual_crop_burnt cannot be null'); + } + $this->container['fraction_of_annual_crop_burnt'] = $fraction_of_annual_crop_burnt; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_allocation + * + * @return float + */ + public function getElectricityAllocation() + { + return $this->container['electricity_allocation']; + } + + /** + * Sets electricity_allocation + * + * @param float $electricity_allocation Percentage of electricity use to allocate to this crop, from 0 to 1 + * + * @return self + */ + public function setElectricityAllocation($electricity_allocation) + { + if (is_null($electricity_allocation)) { + throw new \InvalidArgumentException('non-nullable electricity_allocation cannot be null'); + } + $this->container['electricity_allocation'] = $electricity_allocation; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets diesel_use + * + * @return float + */ + public function getDieselUse() + { + return $this->container['diesel_use']; + } + + /** + * Sets diesel_use + * + * @param float $diesel_use Diesel usage in L (litres) + * + * @return self + */ + public function setDieselUse($diesel_use) + { + if (is_null($diesel_use)) { + throw new \InvalidArgumentException('non-nullable diesel_use cannot be null'); + } + $this->container['diesel_use'] = $diesel_use; + + return $this; + } + + /** + * Gets petrol_use + * + * @return float + */ + public function getPetrolUse() + { + return $this->container['petrol_use']; + } + + /** + * Sets petrol_use + * + * @param float $petrol_use Petrol usage in L (litres) + * + * @return self + */ + public function setPetrolUse($petrol_use) + { + if (is_null($petrol_use)) { + throw new \InvalidArgumentException('non-nullable petrol_use cannot be null'); + } + $this->container['petrol_use'] = $petrol_use; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticulture200Response.php b/examples/php-api-client/api-client/lib/Model/PostHorticulture200Response.php new file mode 100644 index 00000000..a421e726 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticulture200Response.php @@ -0,0 +1,636 @@ + + */ +class PostHorticulture200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostHorticulture200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostCotton200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostHorticulture200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostHorticulture200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration[] $intensities Emissions intensity for each crop (in order) + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInner.php new file mode 100644 index 00000000..1f843813 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostHorticulture200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostHorticulture200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'intensities_with_sequestration' => '\OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'intensities_with_sequestration' => null, + 'net' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'intensities_with_sequestration' => false, + 'net' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'intensities_with_sequestration' => 'intensitiesWithSequestration', + 'net' => 'net', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'intensities_with_sequestration' => 'setIntensitiesWithSequestration', + 'net' => 'setNet', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'intensities_with_sequestration' => 'getIntensitiesWithSequestration', + 'net' => 'getNet', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('intensities_with_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['intensities_with_sequestration'] === null) { + $invalidProperties[] = "'intensities_with_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostHorticulture200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostHorticulture200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets intensities_with_sequestration + * + * @return \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration + */ + public function getIntensitiesWithSequestration() + { + return $this->container['intensities_with_sequestration']; + } + + /** + * Sets intensities_with_sequestration + * + * @param \OpenAPI\Client\Model\PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration $intensities_with_sequestration intensities_with_sequestration + * + * @return self + */ + public function setIntensitiesWithSequestration($intensities_with_sequestration) + { + if (is_null($intensities_with_sequestration)) { + throw new \InvalidArgumentException('non-nullable intensities_with_sequestration cannot be null'); + } + $this->container['intensities_with_sequestration'] = $intensities_with_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.php b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.php new file mode 100644 index 00000000..fb18ad13 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.php @@ -0,0 +1,488 @@ + + */ +class PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_200_response_intermediate_inner_intensitiesWithSequestration'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'crop_produced_tonnes' => 'float', + 'tonnes_crop_excluding_sequestration' => 'float', + 'tonnes_crop_including_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'crop_produced_tonnes' => null, + 'tonnes_crop_excluding_sequestration' => null, + 'tonnes_crop_including_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'crop_produced_tonnes' => false, + 'tonnes_crop_excluding_sequestration' => false, + 'tonnes_crop_including_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'crop_produced_tonnes' => 'cropProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'tonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'tonnesCropIncludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'crop_produced_tonnes' => 'setCropProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'setTonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'setTonnesCropIncludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'crop_produced_tonnes' => 'getCropProducedTonnes', + 'tonnes_crop_excluding_sequestration' => 'getTonnesCropExcludingSequestration', + 'tonnes_crop_including_sequestration' => 'getTonnesCropIncludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('crop_produced_tonnes', $data ?? [], null); + $this->setIfExists('tonnes_crop_excluding_sequestration', $data ?? [], null); + $this->setIfExists('tonnes_crop_including_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['crop_produced_tonnes'] === null) { + $invalidProperties[] = "'crop_produced_tonnes' can't be null"; + } + if ($this->container['tonnes_crop_excluding_sequestration'] === null) { + $invalidProperties[] = "'tonnes_crop_excluding_sequestration' can't be null"; + } + if ($this->container['tonnes_crop_including_sequestration'] === null) { + $invalidProperties[] = "'tonnes_crop_including_sequestration' 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 crop_produced_tonnes + * + * @return float + */ + public function getCropProducedTonnes() + { + return $this->container['crop_produced_tonnes']; + } + + /** + * Sets crop_produced_tonnes + * + * @param float $crop_produced_tonnes Horticultural crop produced in tonnes + * + * @return self + */ + public function setCropProducedTonnes($crop_produced_tonnes) + { + if (is_null($crop_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable crop_produced_tonnes cannot be null'); + } + $this->container['crop_produced_tonnes'] = $crop_produced_tonnes; + + return $this; + } + + /** + * Gets tonnes_crop_excluding_sequestration + * + * @return float + */ + public function getTonnesCropExcludingSequestration() + { + return $this->container['tonnes_crop_excluding_sequestration']; + } + + /** + * Sets tonnes_crop_excluding_sequestration + * + * @param float $tonnes_crop_excluding_sequestration Emissions intensity excluding sequestration, in t-CO2e/t crop + * + * @return self + */ + public function setTonnesCropExcludingSequestration($tonnes_crop_excluding_sequestration) + { + if (is_null($tonnes_crop_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable tonnes_crop_excluding_sequestration cannot be null'); + } + $this->container['tonnes_crop_excluding_sequestration'] = $tonnes_crop_excluding_sequestration; + + return $this; + } + + /** + * Gets tonnes_crop_including_sequestration + * + * @return float + */ + public function getTonnesCropIncludingSequestration() + { + return $this->container['tonnes_crop_including_sequestration']; + } + + /** + * Sets tonnes_crop_including_sequestration + * + * @param float $tonnes_crop_including_sequestration Emissions intensity including sequestration, in t-CO2e/t crop + * + * @return self + */ + public function setTonnesCropIncludingSequestration($tonnes_crop_including_sequestration) + { + if (is_null($tonnes_crop_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable tonnes_crop_including_sequestration cannot be null'); + } + $this->container['tonnes_crop_including_sequestration'] = $tonnes_crop_including_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseScope1.php new file mode 100644 index 00000000..10bc3a8e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticulture200ResponseScope1.php @@ -0,0 +1,1006 @@ + + */ +class PostHorticulture200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'fertiliser_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'crop_residue_n2_o' => 'float', + 'field_burning_n2_o' => 'float', + 'field_burning_ch4' => 'float', + 'hfcs_refrigerant_leakage' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total_hfcs' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'fertiliser_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'crop_residue_n2_o' => null, + 'field_burning_n2_o' => null, + 'field_burning_ch4' => null, + 'hfcs_refrigerant_leakage' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total_hfcs' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'fertiliser_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'crop_residue_n2_o' => false, + 'field_burning_n2_o' => false, + 'field_burning_ch4' => false, + 'hfcs_refrigerant_leakage' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => false, + 'total_hfcs' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'crop_residue_n2_o' => 'cropResidueN2O', + 'field_burning_n2_o' => 'fieldBurningN2O', + 'field_burning_ch4' => 'fieldBurningCH4', + 'hfcs_refrigerant_leakage' => 'hfcsRefrigerantLeakage', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total_hfcs' => 'totalHFCs', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'crop_residue_n2_o' => 'setCropResidueN2O', + 'field_burning_n2_o' => 'setFieldBurningN2O', + 'field_burning_ch4' => 'setFieldBurningCh4', + 'hfcs_refrigerant_leakage' => 'setHfcsRefrigerantLeakage', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total_hfcs' => 'setTotalHfcs', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'crop_residue_n2_o' => 'getCropResidueN2O', + 'field_burning_n2_o' => 'getFieldBurningN2O', + 'field_burning_ch4' => 'getFieldBurningCh4', + 'hfcs_refrigerant_leakage' => 'getHfcsRefrigerantLeakage', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + 'total_hfcs' => 'getTotalHfcs', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('crop_residue_n2_o', $data ?? [], null); + $this->setIfExists('field_burning_n2_o', $data ?? [], null); + $this->setIfExists('field_burning_ch4', $data ?? [], null); + $this->setIfExists('hfcs_refrigerant_leakage', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $data ?? [], null); + $this->setIfExists('total_hfcs', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['crop_residue_n2_o'] === null) { + $invalidProperties[] = "'crop_residue_n2_o' can't be null"; + } + if ($this->container['field_burning_n2_o'] === null) { + $invalidProperties[] = "'field_burning_n2_o' can't be null"; + } + if ($this->container['field_burning_ch4'] === null) { + $invalidProperties[] = "'field_burning_ch4' can't be null"; + } + if ($this->container['hfcs_refrigerant_leakage'] === null) { + $invalidProperties[] = "'hfcs_refrigerant_leakage' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total_hfcs'] === null) { + $invalidProperties[] = "'total_hfcs' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets crop_residue_n2_o + * + * @return float + */ + public function getCropResidueN2O() + { + return $this->container['crop_residue_n2_o']; + } + + /** + * Sets crop_residue_n2_o + * + * @param float $crop_residue_n2_o N2O emissions from crop residue, in tonnes-CO2e + * + * @return self + */ + public function setCropResidueN2O($crop_residue_n2_o) + { + if (is_null($crop_residue_n2_o)) { + throw new \InvalidArgumentException('non-nullable crop_residue_n2_o cannot be null'); + } + $this->container['crop_residue_n2_o'] = $crop_residue_n2_o; + + return $this; + } + + /** + * Gets field_burning_n2_o + * + * @return float + */ + public function getFieldBurningN2O() + { + return $this->container['field_burning_n2_o']; + } + + /** + * Sets field_burning_n2_o + * + * @param float $field_burning_n2_o N2O emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningN2O($field_burning_n2_o) + { + if (is_null($field_burning_n2_o)) { + throw new \InvalidArgumentException('non-nullable field_burning_n2_o cannot be null'); + } + $this->container['field_burning_n2_o'] = $field_burning_n2_o; + + return $this; + } + + /** + * Gets field_burning_ch4 + * + * @return float + */ + public function getFieldBurningCh4() + { + return $this->container['field_burning_ch4']; + } + + /** + * Sets field_burning_ch4 + * + * @param float $field_burning_ch4 CH4 emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningCh4($field_burning_ch4) + { + if (is_null($field_burning_ch4)) { + throw new \InvalidArgumentException('non-nullable field_burning_ch4 cannot be null'); + } + $this->container['field_burning_ch4'] = $field_burning_ch4; + + return $this; + } + + /** + * Gets hfcs_refrigerant_leakage + * + * @return float + */ + public function getHfcsRefrigerantLeakage() + { + return $this->container['hfcs_refrigerant_leakage']; + } + + /** + * Sets hfcs_refrigerant_leakage + * + * @param float $hfcs_refrigerant_leakage Emissions from refrigerant leakage, in tonnes-HFCs + * + * @return self + */ + public function setHfcsRefrigerantLeakage($hfcs_refrigerant_leakage) + { + if (is_null($hfcs_refrigerant_leakage)) { + throw new \InvalidArgumentException('non-nullable hfcs_refrigerant_leakage cannot be null'); + } + $this->container['hfcs_refrigerant_leakage'] = $hfcs_refrigerant_leakage; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total_hfcs + * + * @return float + */ + public function getTotalHfcs() + { + return $this->container['total_hfcs']; + } + + /** + * Sets total_hfcs + * + * @param float $total_hfcs Total HFCs scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalHfcs($total_hfcs) + { + if (is_null($total_hfcs)) { + throw new \InvalidArgumentException('non-nullable total_hfcs cannot be null'); + } + $this->container['total_hfcs'] = $total_hfcs; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticultureRequest.php b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequest.php new file mode 100644 index 00000000..6657a9cd --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequest.php @@ -0,0 +1,626 @@ + + */ +class PostHorticultureRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'crops' => '\OpenAPI\Client\Model\PostHorticultureRequestCropsInner[]', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'vegetation' => '\OpenAPI\Client\Model\PostCottonRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'crops' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'crops' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'crops' => 'crops', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'crops' => 'setCrops', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'crops' => 'getCrops', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets crops + * + * @return \OpenAPI\Client\Model\PostHorticultureRequestCropsInner[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param \OpenAPI\Client\Model\PostHorticultureRequestCropsInner[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostHorticultureRequest., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostHorticultureRequest., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInner.php b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInner.php new file mode 100644 index 00000000..fa54f993 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInner.php @@ -0,0 +1,1264 @@ + + */ +class PostHorticultureRequestCropsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_request_crops_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => 'string', + 'average_yield' => 'float', + 'area_sown' => 'float', + 'urea_application' => 'float', + 'non_urea_nitrogen' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'rainfall_above600' => 'bool', + 'urease_inhibitor_used' => 'bool', + 'nitrification_inhibitor_used' => 'bool', + 'fraction_of_annual_crop_burnt' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_allocation' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'diesel_use' => 'float', + 'petrol_use' => 'float', + 'lpg' => 'float', + 'refrigerants' => '\OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[]' + ]; + + /** + * 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, + 'average_yield' => null, + 'area_sown' => null, + 'urea_application' => null, + 'non_urea_nitrogen' => null, + 'urea_ammonium_nitrate' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'rainfall_above600' => null, + 'urease_inhibitor_used' => null, + 'nitrification_inhibitor_used' => null, + 'fraction_of_annual_crop_burnt' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_allocation' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'diesel_use' => null, + 'petrol_use' => null, + 'lpg' => null, + 'refrigerants' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'type' => false, + 'average_yield' => false, + 'area_sown' => false, + 'urea_application' => false, + 'non_urea_nitrogen' => false, + 'urea_ammonium_nitrate' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'rainfall_above600' => false, + 'urease_inhibitor_used' => false, + 'nitrification_inhibitor_used' => false, + 'fraction_of_annual_crop_burnt' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_allocation' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'diesel_use' => false, + 'petrol_use' => false, + 'lpg' => false, + 'refrigerants' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'average_yield' => 'averageYield', + 'area_sown' => 'areaSown', + 'urea_application' => 'ureaApplication', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'rainfall_above600' => 'rainfallAbove600', + 'urease_inhibitor_used' => 'ureaseInhibitorUsed', + 'nitrification_inhibitor_used' => 'nitrificationInhibitorUsed', + 'fraction_of_annual_crop_burnt' => 'fractionOfAnnualCropBurnt', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_allocation' => 'electricityAllocation', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'diesel_use' => 'dieselUse', + 'petrol_use' => 'petrolUse', + 'lpg' => 'lpg', + 'refrigerants' => 'refrigerants' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'average_yield' => 'setAverageYield', + 'area_sown' => 'setAreaSown', + 'urea_application' => 'setUreaApplication', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'rainfall_above600' => 'setRainfallAbove600', + 'urease_inhibitor_used' => 'setUreaseInhibitorUsed', + 'nitrification_inhibitor_used' => 'setNitrificationInhibitorUsed', + 'fraction_of_annual_crop_burnt' => 'setFractionOfAnnualCropBurnt', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'setElectricityAllocation', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'diesel_use' => 'setDieselUse', + 'petrol_use' => 'setPetrolUse', + 'lpg' => 'setLpg', + 'refrigerants' => 'setRefrigerants' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'average_yield' => 'getAverageYield', + 'area_sown' => 'getAreaSown', + 'urea_application' => 'getUreaApplication', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'rainfall_above600' => 'getRainfallAbove600', + 'urease_inhibitor_used' => 'getUreaseInhibitorUsed', + 'nitrification_inhibitor_used' => 'getNitrificationInhibitorUsed', + 'fraction_of_annual_crop_burnt' => 'getFractionOfAnnualCropBurnt', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'getElectricityAllocation', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'diesel_use' => 'getDieselUse', + 'petrol_use' => 'getPetrolUse', + 'lpg' => 'getLpg', + 'refrigerants' => 'getRefrigerants' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_PULSES = 'Pulses'; + public const TYPE_TUBER_AND_ROOTS = 'Tuber and Roots'; + public const TYPE_PEANUTS = 'Peanuts'; + public const TYPE_HOPS = 'Hops'; + public const TYPE_PERENNIAL_HORT = 'Perennial Hort'; + public const TYPE_ANNUAL_HORT = 'Annual Hort'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_PULSES, + self::TYPE_TUBER_AND_ROOTS, + self::TYPE_PEANUTS, + self::TYPE_HOPS, + self::TYPE_PERENNIAL_HORT, + self::TYPE_ANNUAL_HORT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $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('average_yield', $data ?? [], null); + $this->setIfExists('area_sown', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], null); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], null); + $this->setIfExists('phosphorus_application', $data ?? [], null); + $this->setIfExists('potassium_application', $data ?? [], null); + $this->setIfExists('sulfur_application', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('urease_inhibitor_used', $data ?? [], null); + $this->setIfExists('nitrification_inhibitor_used', $data ?? [], null); + $this->setIfExists('fraction_of_annual_crop_burnt', $data ?? [], null); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_allocation', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('diesel_use', $data ?? [], null); + $this->setIfExists('petrol_use', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('refrigerants', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_yield'] === null) { + $invalidProperties[] = "'average_yield' can't be null"; + } + if ($this->container['area_sown'] === null) { + $invalidProperties[] = "'area_sown' can't be null"; + } + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['fraction_of_annual_crop_burnt'] === null) { + $invalidProperties[] = "'fraction_of_annual_crop_burnt' can't be null"; + } + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_allocation'] === null) { + $invalidProperties[] = "'electricity_allocation' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['diesel_use'] === null) { + $invalidProperties[] = "'diesel_use' can't be null"; + } + if ($this->container['petrol_use'] === null) { + $invalidProperties[] = "'petrol_use' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['refrigerants'] === null) { + $invalidProperties[] = "'refrigerants' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Crop type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets average_yield + * + * @return float + */ + public function getAverageYield() + { + return $this->container['average_yield']; + } + + /** + * Sets average_yield + * + * @param float $average_yield Average crop yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageYield($average_yield) + { + if (is_null($average_yield)) { + throw new \InvalidArgumentException('non-nullable average_yield cannot be null'); + } + $this->container['average_yield'] = $average_yield; + + return $this; + } + + /** + * Gets area_sown + * + * @return float + */ + public function getAreaSown() + { + return $this->container['area_sown']; + } + + /** + * Sets area_sown + * + * @param float $area_sown Area sown, in ha (hectares) + * + * @return self + */ + public function setAreaSown($area_sown) + { + if (is_null($area_sown)) { + throw new \InvalidArgumentException('non-nullable area_sown cannot be null'); + } + $this->container['area_sown'] = $area_sown; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets urease_inhibitor_used + * + * @return bool|null + * @deprecated + */ + public function getUreaseInhibitorUsed() + { + return $this->container['urease_inhibitor_used']; + } + + /** + * Sets urease_inhibitor_used + * + * @param bool|null $urease_inhibitor_used Urease inhibitor used. Deprecation note: No longer used (since v1.1.0) + * + * @return self + * @deprecated + */ + public function setUreaseInhibitorUsed($urease_inhibitor_used) + { + if (is_null($urease_inhibitor_used)) { + throw new \InvalidArgumentException('non-nullable urease_inhibitor_used cannot be null'); + } + $this->container['urease_inhibitor_used'] = $urease_inhibitor_used; + + return $this; + } + + /** + * Gets nitrification_inhibitor_used + * + * @return bool|null + * @deprecated + */ + public function getNitrificationInhibitorUsed() + { + return $this->container['nitrification_inhibitor_used']; + } + + /** + * Sets nitrification_inhibitor_used + * + * @param bool|null $nitrification_inhibitor_used Nitrification inhibitor used. Deprecation note: No longer used (since v1.1.0) + * + * @return self + * @deprecated + */ + public function setNitrificationInhibitorUsed($nitrification_inhibitor_used) + { + if (is_null($nitrification_inhibitor_used)) { + throw new \InvalidArgumentException('non-nullable nitrification_inhibitor_used cannot be null'); + } + $this->container['nitrification_inhibitor_used'] = $nitrification_inhibitor_used; + + return $this; + } + + /** + * Gets fraction_of_annual_crop_burnt + * + * @return float + */ + public function getFractionOfAnnualCropBurnt() + { + return $this->container['fraction_of_annual_crop_burnt']; + } + + /** + * Sets fraction_of_annual_crop_burnt + * + * @param float $fraction_of_annual_crop_burnt Fraction of annual production of crop that is burnt, from 0 to 1 + * + * @return self + */ + public function setFractionOfAnnualCropBurnt($fraction_of_annual_crop_burnt) + { + if (is_null($fraction_of_annual_crop_burnt)) { + throw new \InvalidArgumentException('non-nullable fraction_of_annual_crop_burnt cannot be null'); + } + $this->container['fraction_of_annual_crop_burnt'] = $fraction_of_annual_crop_burnt; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_allocation + * + * @return float + */ + public function getElectricityAllocation() + { + return $this->container['electricity_allocation']; + } + + /** + * Sets electricity_allocation + * + * @param float $electricity_allocation Percentage of electricity use to allocate to this crop, from 0 to 1 + * + * @return self + */ + public function setElectricityAllocation($electricity_allocation) + { + if (is_null($electricity_allocation)) { + throw new \InvalidArgumentException('non-nullable electricity_allocation cannot be null'); + } + $this->container['electricity_allocation'] = $electricity_allocation; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets diesel_use + * + * @return float + */ + public function getDieselUse() + { + return $this->container['diesel_use']; + } + + /** + * Sets diesel_use + * + * @param float $diesel_use Diesel usage in L (litres) + * + * @return self + */ + public function setDieselUse($diesel_use) + { + if (is_null($diesel_use)) { + throw new \InvalidArgumentException('non-nullable diesel_use cannot be null'); + } + $this->container['diesel_use'] = $diesel_use; + + return $this; + } + + /** + * Gets petrol_use + * + * @return float + */ + public function getPetrolUse() + { + return $this->container['petrol_use']; + } + + /** + * Sets petrol_use + * + * @param float $petrol_use Petrol usage in L (litres) + * + * @return self + */ + public function setPetrolUse($petrol_use) + { + if (is_null($petrol_use)) { + throw new \InvalidArgumentException('non-nullable petrol_use cannot be null'); + } + $this->container['petrol_use'] = $petrol_use; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets refrigerants + * + * @return \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] + */ + public function getRefrigerants() + { + return $this->container['refrigerants']; + } + + /** + * Sets refrigerants + * + * @param \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] $refrigerants refrigerants + * + * @return self + */ + public function setRefrigerants($refrigerants) + { + if (is_null($refrigerants)) { + throw new \InvalidArgumentException('non-nullable refrigerants cannot be null'); + } + $this->container['refrigerants'] = $refrigerants; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInnerRefrigerantsInner.php b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInnerRefrigerantsInner.php new file mode 100644 index 00000000..c85344d3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostHorticultureRequestCropsInnerRefrigerantsInner.php @@ -0,0 +1,666 @@ + + */ +class PostHorticultureRequestCropsInnerRefrigerantsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_horticulture_request_crops_inner_refrigerants_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'refrigerant' => 'string', + 'charge_size' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'refrigerant' => null, + 'charge_size' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'refrigerant' => false, + 'charge_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 = [ + 'refrigerant' => 'refrigerant', + 'charge_size' => 'chargeSize' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'refrigerant' => 'setRefrigerant', + 'charge_size' => 'setChargeSize' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'refrigerant' => 'getRefrigerant', + 'charge_size' => 'getChargeSize' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const REFRIGERANT_HFC_23 = 'HFC-23'; + public const REFRIGERANT_HFC_32 = 'HFC-32'; + public const REFRIGERANT_HFC_41 = 'HFC-41'; + public const REFRIGERANT_HFC_43_10MEE = 'HFC-43-10mee'; + public const REFRIGERANT_HFC_125 = 'HFC-125'; + public const REFRIGERANT_HFC_134 = 'HFC-134'; + public const REFRIGERANT_HFC_134A = 'HFC-134a'; + public const REFRIGERANT_HFC_143 = 'HFC-143'; + public const REFRIGERANT_HFC_143A = 'HFC-143a'; + public const REFRIGERANT_HFC_152A = 'HFC-152a'; + public const REFRIGERANT_HFC_227EA = 'HFC-227ea'; + public const REFRIGERANT_HFC_236FA = 'HFC-236fa'; + public const REFRIGERANT_HFC_245CA = 'HFC-245ca'; + public const REFRIGERANT_HFC_245FA = 'HFC-245fa'; + public const REFRIGERANT_HFC_365MFC = 'HFC-365mfc'; + public const REFRIGERANT_R438_A = 'R438A'; + public const REFRIGERANT_R448_A = 'R448A'; + public const REFRIGERANT_R_22 = 'R-22'; + public const REFRIGERANT_AMMONIA__R_717 = 'Ammonia (R-717)'; + public const REFRIGERANT_R_11 = 'R-11'; + public const REFRIGERANT_R_12 = 'R-12'; + public const REFRIGERANT_R_13 = 'R-13'; + public const REFRIGERANT_R_23 = 'R-23'; + public const REFRIGERANT_R_32 = 'R-32'; + public const REFRIGERANT_R_113 = 'R-113'; + public const REFRIGERANT_R_114 = 'R-114'; + public const REFRIGERANT_R_115 = 'R-115'; + public const REFRIGERANT_R_116 = 'R-116'; + public const REFRIGERANT_R_123 = 'R-123'; + public const REFRIGERANT_R_124 = 'R-124'; + public const REFRIGERANT_R_125 = 'R-125'; + public const REFRIGERANT_R_134A = 'R-134a'; + public const REFRIGERANT_R_141B = 'R-141b'; + public const REFRIGERANT_R_142B = 'R-142b'; + public const REFRIGERANT_R_143A = 'R-143a'; + public const REFRIGERANT_R_152A = 'R-152a'; + public const REFRIGERANT_R_218 = 'R-218'; + public const REFRIGERANT_R_227EA = 'R-227ea'; + public const REFRIGERANT_R_236FA = 'R-236fa'; + public const REFRIGERANT_R_245CA = 'R-245ca'; + public const REFRIGERANT_R_245FA = 'R-245fa'; + public const REFRIGERANT_R_C318 = 'R-C318'; + public const REFRIGERANT_R_401_A = 'R-401A'; + public const REFRIGERANT_R_401_B = 'R-401B'; + public const REFRIGERANT_R_401_C = 'R-401C'; + public const REFRIGERANT_R_402_A = 'R-402A'; + public const REFRIGERANT_R_402_B = 'R-402B'; + public const REFRIGERANT_R_403_A = 'R-403A'; + public const REFRIGERANT_R_403_B = 'R-403B'; + public const REFRIGERANT_R_404_A = 'R-404A'; + public const REFRIGERANT_R_405_A = 'R-405A'; + public const REFRIGERANT_R_406_A = 'R-406A'; + public const REFRIGERANT_R_407_A = 'R-407A'; + public const REFRIGERANT_R_407_B = 'R-407B'; + public const REFRIGERANT_R_407_C = 'R-407C'; + public const REFRIGERANT_R_407_D = 'R-407D'; + public const REFRIGERANT_R_407_E = 'R-407E'; + public const REFRIGERANT_R_408_A = 'R-408A'; + public const REFRIGERANT_R_409_A = 'R-409A'; + public const REFRIGERANT_R_409_B = 'R-409B'; + public const REFRIGERANT_R_410_A = 'R-410A'; + public const REFRIGERANT_R_411_A = 'R-411A'; + public const REFRIGERANT_R_411_B = 'R-411B'; + public const REFRIGERANT_R_412_A = 'R-412A'; + public const REFRIGERANT_R_413_A = 'R-413A'; + public const REFRIGERANT_R_414_A = 'R-414A'; + public const REFRIGERANT_R_414_B = 'R-414B'; + public const REFRIGERANT_R_415_A = 'R-415A'; + public const REFRIGERANT_R_415_B = 'R-415B'; + public const REFRIGERANT_R_416_A = 'R-416A'; + public const REFRIGERANT_R_417_A = 'R-417A'; + public const REFRIGERANT_R_418_A = 'R-418A'; + public const REFRIGERANT_R_419_A = 'R-419A'; + public const REFRIGERANT_R_420_A = 'R-420A'; + public const REFRIGERANT_R_421_A = 'R-421A'; + public const REFRIGERANT_R_421_B = 'R-421B'; + public const REFRIGERANT_R_422_A = 'R-422A'; + public const REFRIGERANT_R_422_B = 'R-422B'; + public const REFRIGERANT_R_422_C = 'R-422C'; + public const REFRIGERANT_R_422_D = 'R-422D'; + public const REFRIGERANT_R_423_A = 'R-423A'; + public const REFRIGERANT_R_424_A = 'R-424A'; + public const REFRIGERANT_R_425_A = 'R-425A'; + public const REFRIGERANT_R_426_A = 'R-426A'; + public const REFRIGERANT_R_427_A = 'R-427A'; + public const REFRIGERANT_R_428_A = 'R-428A'; + public const REFRIGERANT_R_500 = 'R-500'; + public const REFRIGERANT_R_502 = 'R-502'; + public const REFRIGERANT_R_503 = 'R-503'; + public const REFRIGERANT_R_507_A = 'R-507A'; + public const REFRIGERANT_R_508_A = 'R-508A'; + public const REFRIGERANT_R_508_B = 'R-508B'; + public const REFRIGERANT_R_509_A = 'R-509A'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRefrigerantAllowableValues() + { + return [ + self::REFRIGERANT_HFC_23, + self::REFRIGERANT_HFC_32, + self::REFRIGERANT_HFC_41, + self::REFRIGERANT_HFC_43_10MEE, + self::REFRIGERANT_HFC_125, + self::REFRIGERANT_HFC_134, + self::REFRIGERANT_HFC_134A, + self::REFRIGERANT_HFC_143, + self::REFRIGERANT_HFC_143A, + self::REFRIGERANT_HFC_152A, + self::REFRIGERANT_HFC_227EA, + self::REFRIGERANT_HFC_236FA, + self::REFRIGERANT_HFC_245CA, + self::REFRIGERANT_HFC_245FA, + self::REFRIGERANT_HFC_365MFC, + self::REFRIGERANT_R438_A, + self::REFRIGERANT_R448_A, + self::REFRIGERANT_R_22, + self::REFRIGERANT_AMMONIA__R_717, + self::REFRIGERANT_R_11, + self::REFRIGERANT_R_12, + self::REFRIGERANT_R_13, + self::REFRIGERANT_R_23, + self::REFRIGERANT_R_32, + self::REFRIGERANT_R_113, + self::REFRIGERANT_R_114, + self::REFRIGERANT_R_115, + self::REFRIGERANT_R_116, + self::REFRIGERANT_R_123, + self::REFRIGERANT_R_124, + self::REFRIGERANT_R_125, + self::REFRIGERANT_R_134A, + self::REFRIGERANT_R_141B, + self::REFRIGERANT_R_142B, + self::REFRIGERANT_R_143A, + self::REFRIGERANT_R_152A, + self::REFRIGERANT_R_218, + self::REFRIGERANT_R_227EA, + self::REFRIGERANT_R_236FA, + self::REFRIGERANT_R_245CA, + self::REFRIGERANT_R_245FA, + self::REFRIGERANT_R_C318, + self::REFRIGERANT_R_401_A, + self::REFRIGERANT_R_401_B, + self::REFRIGERANT_R_401_C, + self::REFRIGERANT_R_402_A, + self::REFRIGERANT_R_402_B, + self::REFRIGERANT_R_403_A, + self::REFRIGERANT_R_403_B, + self::REFRIGERANT_R_404_A, + self::REFRIGERANT_R_405_A, + self::REFRIGERANT_R_406_A, + self::REFRIGERANT_R_407_A, + self::REFRIGERANT_R_407_B, + self::REFRIGERANT_R_407_C, + self::REFRIGERANT_R_407_D, + self::REFRIGERANT_R_407_E, + self::REFRIGERANT_R_408_A, + self::REFRIGERANT_R_409_A, + self::REFRIGERANT_R_409_B, + self::REFRIGERANT_R_410_A, + self::REFRIGERANT_R_411_A, + self::REFRIGERANT_R_411_B, + self::REFRIGERANT_R_412_A, + self::REFRIGERANT_R_413_A, + self::REFRIGERANT_R_414_A, + self::REFRIGERANT_R_414_B, + self::REFRIGERANT_R_415_A, + self::REFRIGERANT_R_415_B, + self::REFRIGERANT_R_416_A, + self::REFRIGERANT_R_417_A, + self::REFRIGERANT_R_418_A, + self::REFRIGERANT_R_419_A, + self::REFRIGERANT_R_420_A, + self::REFRIGERANT_R_421_A, + self::REFRIGERANT_R_421_B, + self::REFRIGERANT_R_422_A, + self::REFRIGERANT_R_422_B, + self::REFRIGERANT_R_422_C, + self::REFRIGERANT_R_422_D, + self::REFRIGERANT_R_423_A, + self::REFRIGERANT_R_424_A, + self::REFRIGERANT_R_425_A, + self::REFRIGERANT_R_426_A, + self::REFRIGERANT_R_427_A, + self::REFRIGERANT_R_428_A, + self::REFRIGERANT_R_500, + self::REFRIGERANT_R_502, + self::REFRIGERANT_R_503, + self::REFRIGERANT_R_507_A, + self::REFRIGERANT_R_508_A, + self::REFRIGERANT_R_508_B, + self::REFRIGERANT_R_509_A, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('refrigerant', $data ?? [], null); + $this->setIfExists('charge_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['refrigerant'] === null) { + $invalidProperties[] = "'refrigerant' can't be null"; + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!is_null($this->container['refrigerant']) && !in_array($this->container['refrigerant'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'refrigerant', must be one of '%s'", + $this->container['refrigerant'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['charge_size'] === null) { + $invalidProperties[] = "'charge_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 refrigerant + * + * @return string + */ + public function getRefrigerant() + { + return $this->container['refrigerant']; + } + + /** + * Sets refrigerant + * + * @param string $refrigerant Refrigerant type + * + * @return self + */ + public function setRefrigerant($refrigerant) + { + if (is_null($refrigerant)) { + throw new \InvalidArgumentException('non-nullable refrigerant cannot be null'); + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!in_array($refrigerant, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'refrigerant', must be one of '%s'", + $refrigerant, + implode("', '", $allowedValues) + ) + ); + } + $this->container['refrigerant'] = $refrigerant; + + return $this; + } + + /** + * Gets charge_size + * + * @return float + */ + public function getChargeSize() + { + return $this->container['charge_size']; + } + + /** + * Sets charge_size + * + * @param float $charge_size Amount of refrigerant contained in the appliance, in kg + * + * @return self + */ + public function setChargeSize($charge_size) + { + if (is_null($charge_size)) { + throw new \InvalidArgumentException('non-nullable charge_size cannot be null'); + } + $this->container['charge_size'] = $charge_size; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200Response.php b/examples/php-api-client/api-client/lib/Model/PostPork200Response.php new file mode 100644 index 00000000..c2c1e850 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200Response.php @@ -0,0 +1,636 @@ + + */ +class PostPork200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostPork200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostPork200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'net' => '\OpenAPI\Client\Model\PostPork200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostPork200ResponseIntensities', + 'intermediate' => '\OpenAPI\Client\Model\PostPork200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostPork200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostPork200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostPork200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostPork200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostPork200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostPork200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostPork200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostPork200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostPork200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostPork200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntensities.php new file mode 100644 index 00000000..b5ddebce --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostPork200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'pork_meat_including_sequestration' => 'float', + 'pork_meat_excluding_sequestration' => 'float', + 'liveweight_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'pork_meat_including_sequestration' => null, + 'pork_meat_excluding_sequestration' => null, + 'liveweight_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'pork_meat_including_sequestration' => false, + 'pork_meat_excluding_sequestration' => false, + 'liveweight_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'pork_meat_including_sequestration' => 'porkMeatIncludingSequestration', + 'pork_meat_excluding_sequestration' => 'porkMeatExcludingSequestration', + 'liveweight_produced_kg' => 'liveweightProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'pork_meat_including_sequestration' => 'setPorkMeatIncludingSequestration', + 'pork_meat_excluding_sequestration' => 'setPorkMeatExcludingSequestration', + 'liveweight_produced_kg' => 'setLiveweightProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'pork_meat_including_sequestration' => 'getPorkMeatIncludingSequestration', + 'pork_meat_excluding_sequestration' => 'getPorkMeatExcludingSequestration', + 'liveweight_produced_kg' => 'getLiveweightProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('pork_meat_including_sequestration', $data ?? [], null); + $this->setIfExists('pork_meat_excluding_sequestration', $data ?? [], null); + $this->setIfExists('liveweight_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['pork_meat_including_sequestration'] === null) { + $invalidProperties[] = "'pork_meat_including_sequestration' can't be null"; + } + if ($this->container['pork_meat_excluding_sequestration'] === null) { + $invalidProperties[] = "'pork_meat_excluding_sequestration' can't be null"; + } + if ($this->container['liveweight_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_produced_kg' 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 pork_meat_including_sequestration + * + * @return float + */ + public function getPorkMeatIncludingSequestration() + { + return $this->container['pork_meat_including_sequestration']; + } + + /** + * Sets pork_meat_including_sequestration + * + * @param float $pork_meat_including_sequestration Pork meat including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPorkMeatIncludingSequestration($pork_meat_including_sequestration) + { + if (is_null($pork_meat_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable pork_meat_including_sequestration cannot be null'); + } + $this->container['pork_meat_including_sequestration'] = $pork_meat_including_sequestration; + + return $this; + } + + /** + * Gets pork_meat_excluding_sequestration + * + * @return float + */ + public function getPorkMeatExcludingSequestration() + { + return $this->container['pork_meat_excluding_sequestration']; + } + + /** + * Sets pork_meat_excluding_sequestration + * + * @param float $pork_meat_excluding_sequestration Pork meat excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPorkMeatExcludingSequestration($pork_meat_excluding_sequestration) + { + if (is_null($pork_meat_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable pork_meat_excluding_sequestration cannot be null'); + } + $this->container['pork_meat_excluding_sequestration'] = $pork_meat_excluding_sequestration; + + return $this; + } + + /** + * Gets liveweight_produced_kg + * + * @return float + */ + public function getLiveweightProducedKg() + { + return $this->container['liveweight_produced_kg']; + } + + /** + * Sets liveweight_produced_kg + * + * @param float $liveweight_produced_kg Pork meat produced in kg liveweight + * + * @return self + */ + public function setLiveweightProducedKg($liveweight_produced_kg) + { + if (is_null($liveweight_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_produced_kg cannot be null'); + } + $this->container['liveweight_produced_kg'] = $liveweight_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntermediateInner.php new file mode 100644 index 00000000..4df426bb --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseIntermediateInner.php @@ -0,0 +1,635 @@ + + */ +class PostPork200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostPork200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostPork200ResponseScope3', + 'carbon_sequestration' => 'float', + 'net' => '\OpenAPI\Client\Model\PostPork200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostPork200ResponseIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 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 scope1 + * + * @return \OpenAPI\Client\Model\PostPork200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostPork200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostPork200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostPork200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostPork200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostPork200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostPork200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostPork200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseNet.php new file mode 100644 index 00000000..d4383217 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostPork200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope1.php new file mode 100644 index 00000000..062f3837 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope1.php @@ -0,0 +1,1006 @@ + + */ +class PostPork200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'urea_co2' => 'float', + 'lime_co2' => 'float', + 'fertiliser_n2_o' => 'float', + 'enteric_ch4' => 'float', + 'manure_management_ch4' => 'float', + 'manure_management_direct_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'atmospheric_deposition_indirect_n2_o' => 'float', + 'leaching_and_runoff_soil_n2_o' => 'float', + 'leaching_and_runoff_mmsn2_o' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'urea_co2' => null, + 'lime_co2' => null, + 'fertiliser_n2_o' => null, + 'enteric_ch4' => null, + 'manure_management_ch4' => null, + 'manure_management_direct_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'atmospheric_deposition_indirect_n2_o' => null, + 'leaching_and_runoff_soil_n2_o' => null, + 'leaching_and_runoff_mmsn2_o' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'urea_co2' => false, + 'lime_co2' => false, + 'fertiliser_n2_o' => false, + 'enteric_ch4' => false, + 'manure_management_ch4' => false, + 'manure_management_direct_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'atmospheric_deposition_indirect_n2_o' => false, + 'leaching_and_runoff_soil_n2_o' => false, + 'leaching_and_runoff_mmsn2_o' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'urea_co2' => 'ureaCO2', + 'lime_co2' => 'limeCO2', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'enteric_ch4' => 'entericCH4', + 'manure_management_ch4' => 'manureManagementCH4', + 'manure_management_direct_n2_o' => 'manureManagementDirectN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'atmospheric_deposition_indirect_n2_o' => 'atmosphericDepositionIndirectN2O', + 'leaching_and_runoff_soil_n2_o' => 'leachingAndRunoffSoilN2O', + 'leaching_and_runoff_mmsn2_o' => 'leachingAndRunoffMMSN2O', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'urea_co2' => 'setUreaCo2', + 'lime_co2' => 'setLimeCo2', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'enteric_ch4' => 'setEntericCh4', + 'manure_management_ch4' => 'setManureManagementCh4', + 'manure_management_direct_n2_o' => 'setManureManagementDirectN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'atmospheric_deposition_indirect_n2_o' => 'setAtmosphericDepositionIndirectN2O', + 'leaching_and_runoff_soil_n2_o' => 'setLeachingAndRunoffSoilN2O', + 'leaching_and_runoff_mmsn2_o' => 'setLeachingAndRunoffMmsn2O', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'urea_co2' => 'getUreaCo2', + 'lime_co2' => 'getLimeCo2', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'enteric_ch4' => 'getEntericCh4', + 'manure_management_ch4' => 'getManureManagementCh4', + 'manure_management_direct_n2_o' => 'getManureManagementDirectN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'atmospheric_deposition_indirect_n2_o' => 'getAtmosphericDepositionIndirectN2O', + 'leaching_and_runoff_soil_n2_o' => 'getLeachingAndRunoffSoilN2O', + 'leaching_and_runoff_mmsn2_o' => 'getLeachingAndRunoffMmsn2O', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('enteric_ch4', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('manure_management_direct_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_indirect_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_soil_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_mmsn2_o', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['enteric_ch4'] === null) { + $invalidProperties[] = "'enteric_ch4' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['manure_management_direct_n2_o'] === null) { + $invalidProperties[] = "'manure_management_direct_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_indirect_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_indirect_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_soil_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_soil_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_mmsn2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_mmsn2_o' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets enteric_ch4 + * + * @return float + */ + public function getEntericCh4() + { + return $this->container['enteric_ch4']; + } + + /** + * Sets enteric_ch4 + * + * @param float $enteric_ch4 CH4 emissions from enteric fermentation, in tonnes-CO2e + * + * @return self + */ + public function setEntericCh4($enteric_ch4) + { + if (is_null($enteric_ch4)) { + throw new \InvalidArgumentException('non-nullable enteric_ch4 cannot be null'); + } + $this->container['enteric_ch4'] = $enteric_ch4; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets manure_management_direct_n2_o + * + * @return float + */ + public function getManureManagementDirectN2O() + { + return $this->container['manure_management_direct_n2_o']; + } + + /** + * Sets manure_management_direct_n2_o + * + * @param float $manure_management_direct_n2_o CH4 emissions from manure management (direct), in tonnes-CO2e + * + * @return self + */ + public function setManureManagementDirectN2O($manure_management_direct_n2_o) + { + if (is_null($manure_management_direct_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_management_direct_n2_o cannot be null'); + } + $this->container['manure_management_direct_n2_o'] = $manure_management_direct_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_indirect_n2_o + * + * @return float + */ + public function getAtmosphericDepositionIndirectN2O() + { + return $this->container['atmospheric_deposition_indirect_n2_o']; + } + + /** + * Sets atmospheric_deposition_indirect_n2_o + * + * @param float $atmospheric_deposition_indirect_n2_o N2O emissions from atmospheric deposition indirect, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionIndirectN2O($atmospheric_deposition_indirect_n2_o) + { + if (is_null($atmospheric_deposition_indirect_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_indirect_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_indirect_n2_o'] = $atmospheric_deposition_indirect_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_soil_n2_o + * + * @return float + */ + public function getLeachingAndRunoffSoilN2O() + { + return $this->container['leaching_and_runoff_soil_n2_o']; + } + + /** + * Sets leaching_and_runoff_soil_n2_o + * + * @param float $leaching_and_runoff_soil_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffSoilN2O($leaching_and_runoff_soil_n2_o) + { + if (is_null($leaching_and_runoff_soil_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_soil_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_soil_n2_o'] = $leaching_and_runoff_soil_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_mmsn2_o + * + * @return float + */ + public function getLeachingAndRunoffMmsn2O() + { + return $this->container['leaching_and_runoff_mmsn2_o']; + } + + /** + * Sets leaching_and_runoff_mmsn2_o + * + * @param float $leaching_and_runoff_mmsn2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffMmsn2O($leaching_and_runoff_mmsn2_o) + { + if (is_null($leaching_and_runoff_mmsn2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_mmsn2_o cannot be null'); + } + $this->container['leaching_and_runoff_mmsn2_o'] = $leaching_and_runoff_mmsn2_o; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope3.php new file mode 100644 index 00000000..43b55b71 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPork200ResponseScope3.php @@ -0,0 +1,710 @@ + + */ +class PostPork200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'purchased_feed' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'purchased_livestock' => 'float', + 'bedding' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'purchased_feed' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'purchased_livestock' => null, + 'bedding' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'purchased_feed' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => false, + 'purchased_livestock' => false, + 'bedding' => 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 = [ + 'fertiliser' => 'fertiliser', + 'purchased_feed' => 'purchasedFeed', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'purchased_livestock' => 'purchasedLivestock', + 'bedding' => 'bedding', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'purchased_feed' => 'setPurchasedFeed', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'purchased_livestock' => 'setPurchasedLivestock', + 'bedding' => 'setBedding', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'purchased_feed' => 'getPurchasedFeed', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + 'purchased_livestock' => 'getPurchasedLivestock', + 'bedding' => 'getBedding', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('purchased_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $data ?? [], null); + $this->setIfExists('purchased_livestock', $data ?? [], null); + $this->setIfExists('bedding', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['purchased_feed'] === null) { + $invalidProperties[] = "'purchased_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['purchased_livestock'] === null) { + $invalidProperties[] = "'purchased_livestock' can't be null"; + } + if ($this->container['bedding'] === null) { + $invalidProperties[] = "'bedding' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets purchased_feed + * + * @return float + */ + public function getPurchasedFeed() + { + return $this->container['purchased_feed']; + } + + /** + * Sets purchased_feed + * + * @param float $purchased_feed Emissions from purchased feed, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedFeed($purchased_feed) + { + if (is_null($purchased_feed)) { + throw new \InvalidArgumentException('non-nullable purchased_feed cannot be null'); + } + $this->container['purchased_feed'] = $purchased_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets purchased_livestock + * + * @return float + */ + public function getPurchasedLivestock() + { + return $this->container['purchased_livestock']; + } + + /** + * Sets purchased_livestock + * + * @param float $purchased_livestock Emissions from purchased pigs, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedLivestock($purchased_livestock) + { + if (is_null($purchased_livestock)) { + throw new \InvalidArgumentException('non-nullable purchased_livestock cannot be null'); + } + $this->container['purchased_livestock'] = $purchased_livestock; + + return $this; + } + + /** + * Gets bedding + * + * @return float + */ + public function getBedding() + { + return $this->container['bedding']; + } + + /** + * Sets bedding + * + * @param float $bedding Emissions from purchased bedding, in tonnes-CO2e + * + * @return self + */ + public function setBedding($bedding) + { + if (is_null($bedding)) { + throw new \InvalidArgumentException('non-nullable bedding cannot be null'); + } + $this->container['bedding'] = $bedding; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequest.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequest.php new file mode 100644 index 00000000..9a6d4965 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequest.php @@ -0,0 +1,612 @@ + + */ +class PostPorkRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'north_of_tropic_of_capricorn' => 'bool', + 'rainfall_above600' => 'bool', + 'pork' => '\OpenAPI\Client\Model\PostPorkRequestPorkInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostPorkRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'north_of_tropic_of_capricorn' => null, + 'rainfall_above600' => null, + 'pork' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'north_of_tropic_of_capricorn' => false, + 'rainfall_above600' => false, + 'pork' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'north_of_tropic_of_capricorn' => 'northOfTropicOfCapricorn', + 'rainfall_above600' => 'rainfallAbove600', + 'pork' => 'pork', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'north_of_tropic_of_capricorn' => 'setNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'setRainfallAbove600', + 'pork' => 'setPork', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'north_of_tropic_of_capricorn' => 'getNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'getRainfallAbove600', + 'pork' => 'getPork', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('north_of_tropic_of_capricorn', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('pork', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['north_of_tropic_of_capricorn'] === null) { + $invalidProperties[] = "'north_of_tropic_of_capricorn' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['pork'] === null) { + $invalidProperties[] = "'pork' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets north_of_tropic_of_capricorn + * + * @return bool + * @deprecated + */ + public function getNorthOfTropicOfCapricorn() + { + return $this->container['north_of_tropic_of_capricorn']; + } + + /** + * Sets north_of_tropic_of_capricorn + * + * @param bool $north_of_tropic_of_capricorn Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude. Deprecation note: This field is deprecated + * + * @return self + * @deprecated + */ + public function setNorthOfTropicOfCapricorn($north_of_tropic_of_capricorn) + { + if (is_null($north_of_tropic_of_capricorn)) { + throw new \InvalidArgumentException('non-nullable north_of_tropic_of_capricorn cannot be null'); + } + $this->container['north_of_tropic_of_capricorn'] = $north_of_tropic_of_capricorn; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets pork + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInner[] + */ + public function getPork() + { + return $this->container['pork']; + } + + /** + * Sets pork + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInner[] $pork pork + * + * @return self + */ + public function setPork($pork) + { + if (is_null($pork)) { + throw new \InvalidArgumentException('non-nullable pork cannot be null'); + } + $this->container['pork'] = $pork; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostPorkRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostPorkRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInner.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInner.php new file mode 100644 index 00000000..588d06b6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInner.php @@ -0,0 +1,978 @@ + + */ +class PostPorkRequestPorkInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'bedding_hay_barley_straw' => 'float', + 'feed_products' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'bedding_hay_barley_straw' => null, + 'feed_products' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'bedding_hay_barley_straw' => false, + 'feed_products' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'bedding_hay_barley_straw' => 'beddingHayBarleyStraw', + 'feed_products' => 'feedProducts' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'bedding_hay_barley_straw' => 'setBeddingHayBarleyStraw', + 'feed_products' => 'setFeedProducts' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'bedding_hay_barley_straw' => 'getBeddingHayBarleyStraw', + 'feed_products' => 'getFeedProducts' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('bedding_hay_barley_straw', $data ?? [], null); + $this->setIfExists('feed_products', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['bedding_hay_barley_straw'] === null) { + $invalidProperties[] = "'bedding_hay_barley_straw' can't be null"; + } + if ($this->container['feed_products'] === null) { + $invalidProperties[] = "'feed_products' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPorkRequestPorkInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPorkRequestPorkInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets bedding_hay_barley_straw + * + * @return float + */ + public function getBeddingHayBarleyStraw() + { + return $this->container['bedding_hay_barley_straw']; + } + + /** + * Sets bedding_hay_barley_straw + * + * @param float $bedding_hay_barley_straw Hay, barley, straw, etc. purchased for pig bedding, in tonnes + * + * @return self + */ + public function setBeddingHayBarleyStraw($bedding_hay_barley_straw) + { + if (is_null($bedding_hay_barley_straw)) { + throw new \InvalidArgumentException('non-nullable bedding_hay_barley_straw cannot be null'); + } + $this->container['bedding_hay_barley_straw'] = $bedding_hay_barley_straw; + + return $this; + } + + /** + * Gets feed_products + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInner[] + */ + public function getFeedProducts() + { + return $this->container['feed_products']; + } + + /** + * Sets feed_products + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInner[] $feed_products feed_products + * + * @return self + */ + public function setFeedProducts($feed_products) + { + if (is_null($feed_products)) { + throw new \InvalidArgumentException('non-nullable feed_products cannot be null'); + } + $this->container['feed_products'] = $feed_products; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClasses.php new file mode 100644 index 00000000..95c1624d --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClasses.php @@ -0,0 +1,615 @@ + + */ +class PostPorkRequestPorkInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sows' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSows', + 'boars' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesBoars', + 'gilts' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGilts', + 'suckers' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSuckers', + 'weaners' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesWeaners', + 'growers' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGrowers', + 'slaughter_pigs' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSlaughterPigs' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sows' => null, + 'boars' => null, + 'gilts' => null, + 'suckers' => null, + 'weaners' => null, + 'growers' => null, + 'slaughter_pigs' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sows' => false, + 'boars' => false, + 'gilts' => false, + 'suckers' => false, + 'weaners' => false, + 'growers' => false, + 'slaughter_pigs' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sows' => 'sows', + 'boars' => 'boars', + 'gilts' => 'gilts', + 'suckers' => 'suckers', + 'weaners' => 'weaners', + 'growers' => 'growers', + 'slaughter_pigs' => 'slaughterPigs' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sows' => 'setSows', + 'boars' => 'setBoars', + 'gilts' => 'setGilts', + 'suckers' => 'setSuckers', + 'weaners' => 'setWeaners', + 'growers' => 'setGrowers', + 'slaughter_pigs' => 'setSlaughterPigs' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sows' => 'getSows', + 'boars' => 'getBoars', + 'gilts' => 'getGilts', + 'suckers' => 'getSuckers', + 'weaners' => 'getWeaners', + 'growers' => 'getGrowers', + 'slaughter_pigs' => 'getSlaughterPigs' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('sows', $data ?? [], null); + $this->setIfExists('boars', $data ?? [], null); + $this->setIfExists('gilts', $data ?? [], null); + $this->setIfExists('suckers', $data ?? [], null); + $this->setIfExists('weaners', $data ?? [], null); + $this->setIfExists('growers', $data ?? [], null); + $this->setIfExists('slaughter_pigs', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 sows + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSows|null + */ + public function getSows() + { + return $this->container['sows']; + } + + /** + * Sets sows + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSows|null $sows sows + * + * @return self + */ + public function setSows($sows) + { + if (is_null($sows)) { + throw new \InvalidArgumentException('non-nullable sows cannot be null'); + } + $this->container['sows'] = $sows; + + return $this; + } + + /** + * Gets boars + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesBoars|null + */ + public function getBoars() + { + return $this->container['boars']; + } + + /** + * Sets boars + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesBoars|null $boars boars + * + * @return self + */ + public function setBoars($boars) + { + if (is_null($boars)) { + throw new \InvalidArgumentException('non-nullable boars cannot be null'); + } + $this->container['boars'] = $boars; + + return $this; + } + + /** + * Gets gilts + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGilts|null + */ + public function getGilts() + { + return $this->container['gilts']; + } + + /** + * Sets gilts + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGilts|null $gilts gilts + * + * @return self + */ + public function setGilts($gilts) + { + if (is_null($gilts)) { + throw new \InvalidArgumentException('non-nullable gilts cannot be null'); + } + $this->container['gilts'] = $gilts; + + return $this; + } + + /** + * Gets suckers + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSuckers|null + */ + public function getSuckers() + { + return $this->container['suckers']; + } + + /** + * Sets suckers + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSuckers|null $suckers suckers + * + * @return self + */ + public function setSuckers($suckers) + { + if (is_null($suckers)) { + throw new \InvalidArgumentException('non-nullable suckers cannot be null'); + } + $this->container['suckers'] = $suckers; + + return $this; + } + + /** + * Gets weaners + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesWeaners|null + */ + public function getWeaners() + { + return $this->container['weaners']; + } + + /** + * Sets weaners + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesWeaners|null $weaners weaners + * + * @return self + */ + public function setWeaners($weaners) + { + if (is_null($weaners)) { + throw new \InvalidArgumentException('non-nullable weaners cannot be null'); + } + $this->container['weaners'] = $weaners; + + return $this; + } + + /** + * Gets growers + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGrowers|null + */ + public function getGrowers() + { + return $this->container['growers']; + } + + /** + * Sets growers + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesGrowers|null $growers growers + * + * @return self + */ + public function setGrowers($growers) + { + if (is_null($growers)) { + throw new \InvalidArgumentException('non-nullable growers cannot be null'); + } + $this->container['growers'] = $growers; + + return $this; + } + + /** + * Gets slaughter_pigs + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSlaughterPigs|null + */ + public function getSlaughterPigs() + { + return $this->container['slaughter_pigs']; + } + + /** + * Sets slaughter_pigs + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSlaughterPigs|null $slaughter_pigs slaughter_pigs + * + * @return self + */ + public function setSlaughterPigs($slaughter_pigs) + { + if (is_null($slaughter_pigs)) { + throw new \InvalidArgumentException('non-nullable slaughter_pigs cannot be null'); + } + $this->container['slaughter_pigs'] = $slaughter_pigs; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesBoars.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesBoars.php new file mode 100644 index 00000000..98a3bb18 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesBoars.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesBoars implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_boars'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGilts.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGilts.php new file mode 100644 index 00000000..ec0598ba --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGilts.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesGilts implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_gilts'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGrowers.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGrowers.php new file mode 100644 index 00000000..b65421ad --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesGrowers.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesGrowers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_growers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSlaughterPigs.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSlaughterPigs.php new file mode 100644 index 00000000..787029d6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSlaughterPigs.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesSlaughterPigs implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_slaughterPigs'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSows.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSows.php new file mode 100644 index 00000000..e78894f0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSows.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesSows implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_sows'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManure.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManure.php new file mode 100644 index 00000000..0cf64a7c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManure.php @@ -0,0 +1,524 @@ + + */ +class PostPorkRequestPorkInnerClassesSowsManure implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_sows_manure'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'spring' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring', + 'summer' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring', + 'autumn' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring', + 'winter' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'spring' => null, + 'summer' => null, + 'autumn' => null, + 'winter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'spring' => false, + 'summer' => false, + 'autumn' => false, + 'winter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'spring' => 'spring', + 'summer' => 'summer', + 'autumn' => 'autumn', + 'winter' => 'winter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'autumn' => 'setAutumn', + 'winter' => 'setWinter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'autumn' => 'getAutumn', + 'winter' => 'getWinter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' 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 spring + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets autumn + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManureSpring $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManureSpring.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManureSpring.php new file mode 100644 index 00000000..9885e2f7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSowsManureSpring.php @@ -0,0 +1,546 @@ + + */ +class PostPorkRequestPorkInnerClassesSowsManureSpring implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_sows_manure_spring'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'outdoor_systems' => 'float', + 'covered_anaerobic_pond' => 'float', + 'uncovered_anaerobic_pond' => 'float', + 'deep_litter' => 'float', + 'undefined_system' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'outdoor_systems' => null, + 'covered_anaerobic_pond' => null, + 'uncovered_anaerobic_pond' => null, + 'deep_litter' => null, + 'undefined_system' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'outdoor_systems' => false, + 'covered_anaerobic_pond' => false, + 'uncovered_anaerobic_pond' => false, + 'deep_litter' => false, + 'undefined_system' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'outdoor_systems' => 'outdoorSystems', + 'covered_anaerobic_pond' => 'coveredAnaerobicPond', + 'uncovered_anaerobic_pond' => 'uncoveredAnaerobicPond', + 'deep_litter' => 'deepLitter', + 'undefined_system' => 'undefinedSystem' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'outdoor_systems' => 'setOutdoorSystems', + 'covered_anaerobic_pond' => 'setCoveredAnaerobicPond', + 'uncovered_anaerobic_pond' => 'setUncoveredAnaerobicPond', + 'deep_litter' => 'setDeepLitter', + 'undefined_system' => 'setUndefinedSystem' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'outdoor_systems' => 'getOutdoorSystems', + 'covered_anaerobic_pond' => 'getCoveredAnaerobicPond', + 'uncovered_anaerobic_pond' => 'getUncoveredAnaerobicPond', + 'deep_litter' => 'getDeepLitter', + 'undefined_system' => 'getUndefinedSystem' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('outdoor_systems', $data ?? [], null); + $this->setIfExists('covered_anaerobic_pond', $data ?? [], null); + $this->setIfExists('uncovered_anaerobic_pond', $data ?? [], null); + $this->setIfExists('deep_litter', $data ?? [], null); + $this->setIfExists('undefined_system', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 outdoor_systems + * + * @return float|null + */ + public function getOutdoorSystems() + { + return $this->container['outdoor_systems']; + } + + /** + * Sets outdoor_systems + * + * @param float|null $outdoor_systems Amount of volatile solids sent to outoor systems in t (tonnes) + * + * @return self + */ + public function setOutdoorSystems($outdoor_systems) + { + if (is_null($outdoor_systems)) { + throw new \InvalidArgumentException('non-nullable outdoor_systems cannot be null'); + } + $this->container['outdoor_systems'] = $outdoor_systems; + + return $this; + } + + /** + * Gets covered_anaerobic_pond + * + * @return float|null + */ + public function getCoveredAnaerobicPond() + { + return $this->container['covered_anaerobic_pond']; + } + + /** + * Sets covered_anaerobic_pond + * + * @param float|null $covered_anaerobic_pond Amount of volatile solids sent to covered anaerobic pond in t (tonnes) + * + * @return self + */ + public function setCoveredAnaerobicPond($covered_anaerobic_pond) + { + if (is_null($covered_anaerobic_pond)) { + throw new \InvalidArgumentException('non-nullable covered_anaerobic_pond cannot be null'); + } + $this->container['covered_anaerobic_pond'] = $covered_anaerobic_pond; + + return $this; + } + + /** + * Gets uncovered_anaerobic_pond + * + * @return float|null + */ + public function getUncoveredAnaerobicPond() + { + return $this->container['uncovered_anaerobic_pond']; + } + + /** + * Sets uncovered_anaerobic_pond + * + * @param float|null $uncovered_anaerobic_pond Amount of volatile solids sent to uncovered anaerobic pond in t (tonnes) + * + * @return self + */ + public function setUncoveredAnaerobicPond($uncovered_anaerobic_pond) + { + if (is_null($uncovered_anaerobic_pond)) { + throw new \InvalidArgumentException('non-nullable uncovered_anaerobic_pond cannot be null'); + } + $this->container['uncovered_anaerobic_pond'] = $uncovered_anaerobic_pond; + + return $this; + } + + /** + * Gets deep_litter + * + * @return float|null + */ + public function getDeepLitter() + { + return $this->container['deep_litter']; + } + + /** + * Sets deep_litter + * + * @param float|null $deep_litter Amount of volatile solids sent to deep litter in t (tonnes) + * + * @return self + */ + public function setDeepLitter($deep_litter) + { + if (is_null($deep_litter)) { + throw new \InvalidArgumentException('non-nullable deep_litter cannot be null'); + } + $this->container['deep_litter'] = $deep_litter; + + return $this; + } + + /** + * Gets undefined_system + * + * @return float|null + */ + public function getUndefinedSystem() + { + return $this->container['undefined_system']; + } + + /** + * Sets undefined_system + * + * @param float|null $undefined_system Amount of volatile solids where manure management system is not known or defined, in t (tonnes) + * + * @return self + */ + public function setUndefinedSystem($undefined_system) + { + if (is_null($undefined_system)) { + throw new \InvalidArgumentException('non-nullable undefined_system cannot be null'); + } + $this->container['undefined_system'] = $undefined_system; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSuckers.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSuckers.php new file mode 100644 index 00000000..9c0390e4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesSuckers.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesSuckers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_suckers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesWeaners.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesWeaners.php new file mode 100644 index 00000000..3aa2aa50 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerClassesWeaners.php @@ -0,0 +1,742 @@ + + */ +class PostPorkRequestPorkInnerClassesWeaners implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_classes_weaners'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]', + 'manure' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null, + 'manure' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false, + 'manure' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases', + 'manure' => 'manure' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases', + 'manure' => 'setManure' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases', + 'manure' => 'getManure' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + $this->setIfExists('manure', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_weight' can't be null"; + } + if ($this->container['manure'] === null) { + $invalidProperties[] = "'manure' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Pig numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Pig numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Pig numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Pig numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + + /** + * Gets manure + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure + */ + public function getManure() + { + return $this->container['manure']; + } + + /** + * Sets manure + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerClassesSowsManure $manure manure + * + * @return self + */ + public function setManure($manure) + { + if (is_null($manure)) { + throw new \InvalidArgumentException('non-nullable manure cannot be null'); + } + $this->container['manure'] = $manure; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInner.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInner.php new file mode 100644 index 00000000..137f3e38 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInner.php @@ -0,0 +1,541 @@ + + */ +class PostPorkRequestPorkInnerFeedProductsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_feedProducts_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feed_purchased' => 'float', + 'additional_ingredients' => 'float', + 'emissions_intensity' => 'float', + 'ingredients' => '\OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInnerIngredients' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feed_purchased' => null, + 'additional_ingredients' => null, + 'emissions_intensity' => null, + 'ingredients' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feed_purchased' => false, + 'additional_ingredients' => false, + 'emissions_intensity' => false, + 'ingredients' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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_purchased' => 'feedPurchased', + 'additional_ingredients' => 'additionalIngredients', + 'emissions_intensity' => 'emissionsIntensity', + 'ingredients' => 'ingredients' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feed_purchased' => 'setFeedPurchased', + 'additional_ingredients' => 'setAdditionalIngredients', + 'emissions_intensity' => 'setEmissionsIntensity', + 'ingredients' => 'setIngredients' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feed_purchased' => 'getFeedPurchased', + 'additional_ingredients' => 'getAdditionalIngredients', + 'emissions_intensity' => 'getEmissionsIntensity', + 'ingredients' => 'getIngredients' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('feed_purchased', $data ?? [], null); + $this->setIfExists('additional_ingredients', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], null); + $this->setIfExists('ingredients', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['feed_purchased'] === null) { + $invalidProperties[] = "'feed_purchased' can't be null"; + } + if ($this->container['additional_ingredients'] === null) { + $invalidProperties[] = "'additional_ingredients' can't be null"; + } + if (($this->container['additional_ingredients'] > 1)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be smaller than or equal to 1."; + } + + if (($this->container['additional_ingredients'] < 0)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be bigger than or equal to 0."; + } + + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' can't be null"; + } + if ($this->container['ingredients'] === null) { + $invalidProperties[] = "'ingredients' 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_purchased + * + * @return float + */ + public function getFeedPurchased() + { + return $this->container['feed_purchased']; + } + + /** + * Sets feed_purchased + * + * @param float $feed_purchased Pig feed purchased, in tonnes + * + * @return self + */ + public function setFeedPurchased($feed_purchased) + { + if (is_null($feed_purchased)) { + throw new \InvalidArgumentException('non-nullable feed_purchased cannot be null'); + } + $this->container['feed_purchased'] = $feed_purchased; + + return $this; + } + + /** + * Gets additional_ingredients + * + * @return float + */ + public function getAdditionalIngredients() + { + return $this->container['additional_ingredients']; + } + + /** + * Sets additional_ingredients + * + * @param float $additional_ingredients Fraction of additional ingredient in feed mix, from 0 to 1 + * + * @return self + */ + public function setAdditionalIngredients($additional_ingredients) + { + if (is_null($additional_ingredients)) { + throw new \InvalidArgumentException('non-nullable additional_ingredients cannot be null'); + } + + if (($additional_ingredients > 1)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostPorkRequestPorkInnerFeedProductsInner., must be smaller than or equal to 1.'); + } + if (($additional_ingredients < 0)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostPorkRequestPorkInnerFeedProductsInner., must be bigger than or equal to 0.'); + } + + $this->container['additional_ingredients'] = $additional_ingredients; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of feed product in GHG (kg CO2-e/kg input) + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + + /** + * Gets ingredients + * + * @return \OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInnerIngredients + */ + public function getIngredients() + { + return $this->container['ingredients']; + } + + /** + * Sets ingredients + * + * @param \OpenAPI\Client\Model\PostPorkRequestPorkInnerFeedProductsInnerIngredients $ingredients ingredients + * + * @return self + */ + public function setIngredients($ingredients) + { + if (is_null($ingredients)) { + throw new \InvalidArgumentException('non-nullable ingredients cannot be null'); + } + $this->container['ingredients'] = $ingredients; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInnerIngredients.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInnerIngredients.php new file mode 100644 index 00000000..a65a8114 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestPorkInnerFeedProductsInnerIngredients.php @@ -0,0 +1,977 @@ + + */ +class PostPorkRequestPorkInnerFeedProductsInnerIngredients implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_pork_inner_feedProducts_inner_ingredients'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'wheat' => 'float', + 'barley' => 'float', + 'whey_powder' => 'float', + 'canola_meal' => 'float', + 'soybean_meal' => 'float', + 'meat_meal' => 'float', + 'blood_meal' => 'float', + 'fishmeal' => 'float', + 'tallow' => 'float', + 'wheat_bran' => 'float', + 'beet_pulp' => 'float', + 'mill_mix' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'wheat' => null, + 'barley' => null, + 'whey_powder' => null, + 'canola_meal' => null, + 'soybean_meal' => null, + 'meat_meal' => null, + 'blood_meal' => null, + 'fishmeal' => null, + 'tallow' => null, + 'wheat_bran' => null, + 'beet_pulp' => null, + 'mill_mix' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'wheat' => false, + 'barley' => false, + 'whey_powder' => false, + 'canola_meal' => false, + 'soybean_meal' => false, + 'meat_meal' => false, + 'blood_meal' => false, + 'fishmeal' => false, + 'tallow' => false, + 'wheat_bran' => false, + 'beet_pulp' => false, + 'mill_mix' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'wheat' => 'wheat', + 'barley' => 'barley', + 'whey_powder' => 'wheyPowder', + 'canola_meal' => 'canolaMeal', + 'soybean_meal' => 'soybeanMeal', + 'meat_meal' => 'meatMeal', + 'blood_meal' => 'bloodMeal', + 'fishmeal' => 'fishmeal', + 'tallow' => 'tallow', + 'wheat_bran' => 'wheatBran', + 'beet_pulp' => 'beetPulp', + 'mill_mix' => 'millMix' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'wheat' => 'setWheat', + 'barley' => 'setBarley', + 'whey_powder' => 'setWheyPowder', + 'canola_meal' => 'setCanolaMeal', + 'soybean_meal' => 'setSoybeanMeal', + 'meat_meal' => 'setMeatMeal', + 'blood_meal' => 'setBloodMeal', + 'fishmeal' => 'setFishmeal', + 'tallow' => 'setTallow', + 'wheat_bran' => 'setWheatBran', + 'beet_pulp' => 'setBeetPulp', + 'mill_mix' => 'setMillMix' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'wheat' => 'getWheat', + 'barley' => 'getBarley', + 'whey_powder' => 'getWheyPowder', + 'canola_meal' => 'getCanolaMeal', + 'soybean_meal' => 'getSoybeanMeal', + 'meat_meal' => 'getMeatMeal', + 'blood_meal' => 'getBloodMeal', + 'fishmeal' => 'getFishmeal', + 'tallow' => 'getTallow', + 'wheat_bran' => 'getWheatBran', + 'beet_pulp' => 'getBeetPulp', + 'mill_mix' => 'getMillMix' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('wheat', $data ?? [], null); + $this->setIfExists('barley', $data ?? [], null); + $this->setIfExists('whey_powder', $data ?? [], null); + $this->setIfExists('canola_meal', $data ?? [], null); + $this->setIfExists('soybean_meal', $data ?? [], null); + $this->setIfExists('meat_meal', $data ?? [], null); + $this->setIfExists('blood_meal', $data ?? [], null); + $this->setIfExists('fishmeal', $data ?? [], null); + $this->setIfExists('tallow', $data ?? [], null); + $this->setIfExists('wheat_bran', $data ?? [], null); + $this->setIfExists('beet_pulp', $data ?? [], null); + $this->setIfExists('mill_mix', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['wheat']) && ($this->container['wheat'] > 1)) { + $invalidProperties[] = "invalid value for 'wheat', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['wheat']) && ($this->container['wheat'] < 0)) { + $invalidProperties[] = "invalid value for 'wheat', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['barley']) && ($this->container['barley'] > 1)) { + $invalidProperties[] = "invalid value for 'barley', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['barley']) && ($this->container['barley'] < 0)) { + $invalidProperties[] = "invalid value for 'barley', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['whey_powder']) && ($this->container['whey_powder'] > 1)) { + $invalidProperties[] = "invalid value for 'whey_powder', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['whey_powder']) && ($this->container['whey_powder'] < 0)) { + $invalidProperties[] = "invalid value for 'whey_powder', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['canola_meal']) && ($this->container['canola_meal'] > 1)) { + $invalidProperties[] = "invalid value for 'canola_meal', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['canola_meal']) && ($this->container['canola_meal'] < 0)) { + $invalidProperties[] = "invalid value for 'canola_meal', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['soybean_meal']) && ($this->container['soybean_meal'] > 1)) { + $invalidProperties[] = "invalid value for 'soybean_meal', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['soybean_meal']) && ($this->container['soybean_meal'] < 0)) { + $invalidProperties[] = "invalid value for 'soybean_meal', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['meat_meal']) && ($this->container['meat_meal'] > 1)) { + $invalidProperties[] = "invalid value for 'meat_meal', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['meat_meal']) && ($this->container['meat_meal'] < 0)) { + $invalidProperties[] = "invalid value for 'meat_meal', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['blood_meal']) && ($this->container['blood_meal'] > 1)) { + $invalidProperties[] = "invalid value for 'blood_meal', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['blood_meal']) && ($this->container['blood_meal'] < 0)) { + $invalidProperties[] = "invalid value for 'blood_meal', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['fishmeal']) && ($this->container['fishmeal'] > 1)) { + $invalidProperties[] = "invalid value for 'fishmeal', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['fishmeal']) && ($this->container['fishmeal'] < 0)) { + $invalidProperties[] = "invalid value for 'fishmeal', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['tallow']) && ($this->container['tallow'] > 1)) { + $invalidProperties[] = "invalid value for 'tallow', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['tallow']) && ($this->container['tallow'] < 0)) { + $invalidProperties[] = "invalid value for 'tallow', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['wheat_bran']) && ($this->container['wheat_bran'] > 1)) { + $invalidProperties[] = "invalid value for 'wheat_bran', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['wheat_bran']) && ($this->container['wheat_bran'] < 0)) { + $invalidProperties[] = "invalid value for 'wheat_bran', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['beet_pulp']) && ($this->container['beet_pulp'] > 1)) { + $invalidProperties[] = "invalid value for 'beet_pulp', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['beet_pulp']) && ($this->container['beet_pulp'] < 0)) { + $invalidProperties[] = "invalid value for 'beet_pulp', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['mill_mix']) && ($this->container['mill_mix'] > 1)) { + $invalidProperties[] = "invalid value for 'mill_mix', must be smaller than or equal to 1."; + } + + if (!is_null($this->container['mill_mix']) && ($this->container['mill_mix'] < 0)) { + $invalidProperties[] = "invalid value for 'mill_mix', 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 wheat + * + * @return float|null + */ + public function getWheat() + { + return $this->container['wheat']; + } + + /** + * Sets wheat + * + * @param float|null $wheat wheat + * + * @return self + */ + public function setWheat($wheat) + { + if (is_null($wheat)) { + throw new \InvalidArgumentException('non-nullable wheat cannot be null'); + } + + if (($wheat > 1)) { + throw new \InvalidArgumentException('invalid value for $wheat when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($wheat < 0)) { + throw new \InvalidArgumentException('invalid value for $wheat when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['wheat'] = $wheat; + + return $this; + } + + /** + * Gets barley + * + * @return float|null + */ + public function getBarley() + { + return $this->container['barley']; + } + + /** + * Sets barley + * + * @param float|null $barley barley + * + * @return self + */ + public function setBarley($barley) + { + if (is_null($barley)) { + throw new \InvalidArgumentException('non-nullable barley cannot be null'); + } + + if (($barley > 1)) { + throw new \InvalidArgumentException('invalid value for $barley when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($barley < 0)) { + throw new \InvalidArgumentException('invalid value for $barley when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['barley'] = $barley; + + return $this; + } + + /** + * Gets whey_powder + * + * @return float|null + */ + public function getWheyPowder() + { + return $this->container['whey_powder']; + } + + /** + * Sets whey_powder + * + * @param float|null $whey_powder whey_powder + * + * @return self + */ + public function setWheyPowder($whey_powder) + { + if (is_null($whey_powder)) { + throw new \InvalidArgumentException('non-nullable whey_powder cannot be null'); + } + + if (($whey_powder > 1)) { + throw new \InvalidArgumentException('invalid value for $whey_powder when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($whey_powder < 0)) { + throw new \InvalidArgumentException('invalid value for $whey_powder when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['whey_powder'] = $whey_powder; + + return $this; + } + + /** + * Gets canola_meal + * + * @return float|null + */ + public function getCanolaMeal() + { + return $this->container['canola_meal']; + } + + /** + * Sets canola_meal + * + * @param float|null $canola_meal canola_meal + * + * @return self + */ + public function setCanolaMeal($canola_meal) + { + if (is_null($canola_meal)) { + throw new \InvalidArgumentException('non-nullable canola_meal cannot be null'); + } + + if (($canola_meal > 1)) { + throw new \InvalidArgumentException('invalid value for $canola_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($canola_meal < 0)) { + throw new \InvalidArgumentException('invalid value for $canola_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['canola_meal'] = $canola_meal; + + return $this; + } + + /** + * Gets soybean_meal + * + * @return float|null + */ + public function getSoybeanMeal() + { + return $this->container['soybean_meal']; + } + + /** + * Sets soybean_meal + * + * @param float|null $soybean_meal soybean_meal + * + * @return self + */ + public function setSoybeanMeal($soybean_meal) + { + if (is_null($soybean_meal)) { + throw new \InvalidArgumentException('non-nullable soybean_meal cannot be null'); + } + + if (($soybean_meal > 1)) { + throw new \InvalidArgumentException('invalid value for $soybean_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($soybean_meal < 0)) { + throw new \InvalidArgumentException('invalid value for $soybean_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['soybean_meal'] = $soybean_meal; + + return $this; + } + + /** + * Gets meat_meal + * + * @return float|null + */ + public function getMeatMeal() + { + return $this->container['meat_meal']; + } + + /** + * Sets meat_meal + * + * @param float|null $meat_meal meat_meal + * + * @return self + */ + public function setMeatMeal($meat_meal) + { + if (is_null($meat_meal)) { + throw new \InvalidArgumentException('non-nullable meat_meal cannot be null'); + } + + if (($meat_meal > 1)) { + throw new \InvalidArgumentException('invalid value for $meat_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($meat_meal < 0)) { + throw new \InvalidArgumentException('invalid value for $meat_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['meat_meal'] = $meat_meal; + + return $this; + } + + /** + * Gets blood_meal + * + * @return float|null + */ + public function getBloodMeal() + { + return $this->container['blood_meal']; + } + + /** + * Sets blood_meal + * + * @param float|null $blood_meal blood_meal + * + * @return self + */ + public function setBloodMeal($blood_meal) + { + if (is_null($blood_meal)) { + throw new \InvalidArgumentException('non-nullable blood_meal cannot be null'); + } + + if (($blood_meal > 1)) { + throw new \InvalidArgumentException('invalid value for $blood_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($blood_meal < 0)) { + throw new \InvalidArgumentException('invalid value for $blood_meal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['blood_meal'] = $blood_meal; + + return $this; + } + + /** + * Gets fishmeal + * + * @return float|null + */ + public function getFishmeal() + { + return $this->container['fishmeal']; + } + + /** + * Sets fishmeal + * + * @param float|null $fishmeal fishmeal + * + * @return self + */ + public function setFishmeal($fishmeal) + { + if (is_null($fishmeal)) { + throw new \InvalidArgumentException('non-nullable fishmeal cannot be null'); + } + + if (($fishmeal > 1)) { + throw new \InvalidArgumentException('invalid value for $fishmeal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($fishmeal < 0)) { + throw new \InvalidArgumentException('invalid value for $fishmeal when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['fishmeal'] = $fishmeal; + + return $this; + } + + /** + * Gets tallow + * + * @return float|null + */ + public function getTallow() + { + return $this->container['tallow']; + } + + /** + * Sets tallow + * + * @param float|null $tallow tallow + * + * @return self + */ + public function setTallow($tallow) + { + if (is_null($tallow)) { + throw new \InvalidArgumentException('non-nullable tallow cannot be null'); + } + + if (($tallow > 1)) { + throw new \InvalidArgumentException('invalid value for $tallow when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($tallow < 0)) { + throw new \InvalidArgumentException('invalid value for $tallow when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['tallow'] = $tallow; + + return $this; + } + + /** + * Gets wheat_bran + * + * @return float|null + */ + public function getWheatBran() + { + return $this->container['wheat_bran']; + } + + /** + * Sets wheat_bran + * + * @param float|null $wheat_bran wheat_bran + * + * @return self + */ + public function setWheatBran($wheat_bran) + { + if (is_null($wheat_bran)) { + throw new \InvalidArgumentException('non-nullable wheat_bran cannot be null'); + } + + if (($wheat_bran > 1)) { + throw new \InvalidArgumentException('invalid value for $wheat_bran when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($wheat_bran < 0)) { + throw new \InvalidArgumentException('invalid value for $wheat_bran when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['wheat_bran'] = $wheat_bran; + + return $this; + } + + /** + * Gets beet_pulp + * + * @return float|null + */ + public function getBeetPulp() + { + return $this->container['beet_pulp']; + } + + /** + * Sets beet_pulp + * + * @param float|null $beet_pulp beet_pulp + * + * @return self + */ + public function setBeetPulp($beet_pulp) + { + if (is_null($beet_pulp)) { + throw new \InvalidArgumentException('non-nullable beet_pulp cannot be null'); + } + + if (($beet_pulp > 1)) { + throw new \InvalidArgumentException('invalid value for $beet_pulp when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($beet_pulp < 0)) { + throw new \InvalidArgumentException('invalid value for $beet_pulp when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['beet_pulp'] = $beet_pulp; + + return $this; + } + + /** + * Gets mill_mix + * + * @return float|null + */ + public function getMillMix() + { + return $this->container['mill_mix']; + } + + /** + * Sets mill_mix + * + * @param float|null $mill_mix mill_mix + * + * @return self + */ + public function setMillMix($mill_mix) + { + if (is_null($mill_mix)) { + throw new \InvalidArgumentException('non-nullable mill_mix cannot be null'); + } + + if (($mill_mix > 1)) { + throw new \InvalidArgumentException('invalid value for $mill_mix when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be smaller than or equal to 1.'); + } + if (($mill_mix < 0)) { + throw new \InvalidArgumentException('invalid value for $mill_mix when calling PostPorkRequestPorkInnerFeedProductsInnerIngredients., must be bigger than or equal to 0.'); + } + + $this->container['mill_mix'] = $mill_mix; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPorkRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostPorkRequestVegetationInner.php new file mode 100644 index 00000000..72858454 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPorkRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostPorkRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_pork_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'allocated_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'allocated_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'allocated_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'allocated_proportion' => 'allocatedProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'allocated_proportion' => 'setAllocatedProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'allocated_proportion' => 'getAllocatedProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('allocated_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['allocated_proportion'] === null) { + $invalidProperties[] = "'allocated_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets allocated_proportion + * + * @return float[] + */ + public function getAllocatedProportion() + { + return $this->container['allocated_proportion']; + } + + /** + * Sets allocated_proportion + * + * @param float[] $allocated_proportion The proportion of the sequestration that is allocated to the activity + * + * @return self + */ + public function setAllocatedProportion($allocated_proportion) + { + if (is_null($allocated_proportion)) { + throw new \InvalidArgumentException('non-nullable allocated_proportion cannot be null'); + } + $this->container['allocated_proportion'] = $allocated_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200Response.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200Response.php new file mode 100644 index 00000000..5435637c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200Response.php @@ -0,0 +1,673 @@ + + */ +class PostPoultry200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate_broilers' => '\OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInner[]', + 'intermediate_layers' => '\OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInner[]', + 'net' => '\OpenAPI\Client\Model\PostPoultry200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostPoultry200ResponseIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate_broilers' => null, + 'intermediate_layers' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate_broilers' => false, + 'intermediate_layers' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate_broilers' => 'intermediateBroilers', + 'intermediate_layers' => 'intermediateLayers', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate_broilers' => 'setIntermediateBroilers', + 'intermediate_layers' => 'setIntermediateLayers', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate_broilers' => 'getIntermediateBroilers', + 'intermediate_layers' => 'getIntermediateLayers', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate_broilers', $data ?? [], null); + $this->setIfExists('intermediate_layers', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate_broilers'] === null) { + $invalidProperties[] = "'intermediate_broilers' can't be null"; + } + if ($this->container['intermediate_layers'] === null) { + $invalidProperties[] = "'intermediate_layers' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate_broilers + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInner[] + */ + public function getIntermediateBroilers() + { + return $this->container['intermediate_broilers']; + } + + /** + * Sets intermediate_broilers + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInner[] $intermediate_broilers intermediate_broilers + * + * @return self + */ + public function setIntermediateBroilers($intermediate_broilers) + { + if (is_null($intermediate_broilers)) { + throw new \InvalidArgumentException('non-nullable intermediate_broilers cannot be null'); + } + $this->container['intermediate_broilers'] = $intermediate_broilers; + + return $this; + } + + /** + * Gets intermediate_layers + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInner[] + */ + public function getIntermediateLayers() + { + return $this->container['intermediate_layers']; + } + + /** + * Sets intermediate_layers + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInner[] $intermediate_layers intermediate_layers + * + * @return self + */ + public function setIntermediateLayers($intermediate_layers) + { + if (is_null($intermediate_layers)) { + throw new \InvalidArgumentException('non-nullable intermediate_layers cannot be null'); + } + $this->container['intermediate_layers'] = $intermediate_layers; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntensities.php new file mode 100644 index 00000000..0d5eddc6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntensities.php @@ -0,0 +1,598 @@ + + */ +class PostPoultry200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'poultry_meat_including_sequestration' => 'float', + 'poultry_meat_excluding_sequestration' => 'float', + 'poultry_eggs_including_sequestration' => 'float', + 'poultry_eggs_excluding_sequestration' => 'float', + 'meat_produced_kg' => 'float', + 'eggs_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'poultry_meat_including_sequestration' => null, + 'poultry_meat_excluding_sequestration' => null, + 'poultry_eggs_including_sequestration' => null, + 'poultry_eggs_excluding_sequestration' => null, + 'meat_produced_kg' => null, + 'eggs_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'poultry_meat_including_sequestration' => false, + 'poultry_meat_excluding_sequestration' => false, + 'poultry_eggs_including_sequestration' => false, + 'poultry_eggs_excluding_sequestration' => false, + 'meat_produced_kg' => false, + 'eggs_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'poultry_meat_including_sequestration' => 'poultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'poultryMeatExcludingSequestration', + 'poultry_eggs_including_sequestration' => 'poultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'poultryEggsExcludingSequestration', + 'meat_produced_kg' => 'meatProducedKg', + 'eggs_produced_kg' => 'eggsProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'poultry_meat_including_sequestration' => 'setPoultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'setPoultryMeatExcludingSequestration', + 'poultry_eggs_including_sequestration' => 'setPoultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'setPoultryEggsExcludingSequestration', + 'meat_produced_kg' => 'setMeatProducedKg', + 'eggs_produced_kg' => 'setEggsProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'poultry_meat_including_sequestration' => 'getPoultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'getPoultryMeatExcludingSequestration', + 'poultry_eggs_including_sequestration' => 'getPoultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'getPoultryEggsExcludingSequestration', + 'meat_produced_kg' => 'getMeatProducedKg', + 'eggs_produced_kg' => 'getEggsProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('poultry_meat_including_sequestration', $data ?? [], null); + $this->setIfExists('poultry_meat_excluding_sequestration', $data ?? [], null); + $this->setIfExists('poultry_eggs_including_sequestration', $data ?? [], null); + $this->setIfExists('poultry_eggs_excluding_sequestration', $data ?? [], null); + $this->setIfExists('meat_produced_kg', $data ?? [], null); + $this->setIfExists('eggs_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['poultry_meat_including_sequestration'] === null) { + $invalidProperties[] = "'poultry_meat_including_sequestration' can't be null"; + } + if ($this->container['poultry_meat_excluding_sequestration'] === null) { + $invalidProperties[] = "'poultry_meat_excluding_sequestration' can't be null"; + } + if ($this->container['poultry_eggs_including_sequestration'] === null) { + $invalidProperties[] = "'poultry_eggs_including_sequestration' can't be null"; + } + if ($this->container['poultry_eggs_excluding_sequestration'] === null) { + $invalidProperties[] = "'poultry_eggs_excluding_sequestration' can't be null"; + } + if ($this->container['meat_produced_kg'] === null) { + $invalidProperties[] = "'meat_produced_kg' can't be null"; + } + if ($this->container['eggs_produced_kg'] === null) { + $invalidProperties[] = "'eggs_produced_kg' 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 poultry_meat_including_sequestration + * + * @return float + */ + public function getPoultryMeatIncludingSequestration() + { + return $this->container['poultry_meat_including_sequestration']; + } + + /** + * Sets poultry_meat_including_sequestration + * + * @param float $poultry_meat_including_sequestration Poultry meat including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryMeatIncludingSequestration($poultry_meat_including_sequestration) + { + if (is_null($poultry_meat_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_meat_including_sequestration cannot be null'); + } + $this->container['poultry_meat_including_sequestration'] = $poultry_meat_including_sequestration; + + return $this; + } + + /** + * Gets poultry_meat_excluding_sequestration + * + * @return float + */ + public function getPoultryMeatExcludingSequestration() + { + return $this->container['poultry_meat_excluding_sequestration']; + } + + /** + * Sets poultry_meat_excluding_sequestration + * + * @param float $poultry_meat_excluding_sequestration Poultry meat excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryMeatExcludingSequestration($poultry_meat_excluding_sequestration) + { + if (is_null($poultry_meat_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_meat_excluding_sequestration cannot be null'); + } + $this->container['poultry_meat_excluding_sequestration'] = $poultry_meat_excluding_sequestration; + + return $this; + } + + /** + * Gets poultry_eggs_including_sequestration + * + * @return float + */ + public function getPoultryEggsIncludingSequestration() + { + return $this->container['poultry_eggs_including_sequestration']; + } + + /** + * Sets poultry_eggs_including_sequestration + * + * @param float $poultry_eggs_including_sequestration Poultry eggs including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryEggsIncludingSequestration($poultry_eggs_including_sequestration) + { + if (is_null($poultry_eggs_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_eggs_including_sequestration cannot be null'); + } + $this->container['poultry_eggs_including_sequestration'] = $poultry_eggs_including_sequestration; + + return $this; + } + + /** + * Gets poultry_eggs_excluding_sequestration + * + * @return float + */ + public function getPoultryEggsExcludingSequestration() + { + return $this->container['poultry_eggs_excluding_sequestration']; + } + + /** + * Sets poultry_eggs_excluding_sequestration + * + * @param float $poultry_eggs_excluding_sequestration Poultry eggs excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryEggsExcludingSequestration($poultry_eggs_excluding_sequestration) + { + if (is_null($poultry_eggs_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_eggs_excluding_sequestration cannot be null'); + } + $this->container['poultry_eggs_excluding_sequestration'] = $poultry_eggs_excluding_sequestration; + + return $this; + } + + /** + * Gets meat_produced_kg + * + * @return float + */ + public function getMeatProducedKg() + { + return $this->container['meat_produced_kg']; + } + + /** + * Sets meat_produced_kg + * + * @param float $meat_produced_kg Poultry meat produced in kg + * + * @return self + */ + public function setMeatProducedKg($meat_produced_kg) + { + if (is_null($meat_produced_kg)) { + throw new \InvalidArgumentException('non-nullable meat_produced_kg cannot be null'); + } + $this->container['meat_produced_kg'] = $meat_produced_kg; + + return $this; + } + + /** + * Gets eggs_produced_kg + * + * @return float + */ + public function getEggsProducedKg() + { + return $this->container['eggs_produced_kg']; + } + + /** + * Sets eggs_produced_kg + * + * @param float $eggs_produced_kg Amount of eggs produced, in kg + * + * @return self + */ + public function setEggsProducedKg($eggs_produced_kg) + { + if (is_null($eggs_produced_kg)) { + throw new \InvalidArgumentException('non-nullable eggs_produced_kg cannot be null'); + } + $this->container['eggs_produced_kg'] = $eggs_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInner.php new file mode 100644 index 00000000..199a3770 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInner.php @@ -0,0 +1,635 @@ + + */ +class PostPoultry200ResponseIntermediateBroilersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_intermediateBroilers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration', + 'intensities' => '\OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 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 scope1 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateBroilersInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInnerIntensities.php new file mode 100644 index 00000000..2db148b6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateBroilersInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostPoultry200ResponseIntermediateBroilersInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_intermediateBroilers_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'poultry_meat_including_sequestration' => 'float', + 'poultry_meat_excluding_sequestration' => 'float', + 'meat_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'poultry_meat_including_sequestration' => null, + 'poultry_meat_excluding_sequestration' => null, + 'meat_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'poultry_meat_including_sequestration' => false, + 'poultry_meat_excluding_sequestration' => false, + 'meat_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'poultry_meat_including_sequestration' => 'poultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'poultryMeatExcludingSequestration', + 'meat_produced_kg' => 'meatProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'poultry_meat_including_sequestration' => 'setPoultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'setPoultryMeatExcludingSequestration', + 'meat_produced_kg' => 'setMeatProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'poultry_meat_including_sequestration' => 'getPoultryMeatIncludingSequestration', + 'poultry_meat_excluding_sequestration' => 'getPoultryMeatExcludingSequestration', + 'meat_produced_kg' => 'getMeatProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('poultry_meat_including_sequestration', $data ?? [], null); + $this->setIfExists('poultry_meat_excluding_sequestration', $data ?? [], null); + $this->setIfExists('meat_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['poultry_meat_including_sequestration'] === null) { + $invalidProperties[] = "'poultry_meat_including_sequestration' can't be null"; + } + if ($this->container['poultry_meat_excluding_sequestration'] === null) { + $invalidProperties[] = "'poultry_meat_excluding_sequestration' can't be null"; + } + if ($this->container['meat_produced_kg'] === null) { + $invalidProperties[] = "'meat_produced_kg' 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 poultry_meat_including_sequestration + * + * @return float + */ + public function getPoultryMeatIncludingSequestration() + { + return $this->container['poultry_meat_including_sequestration']; + } + + /** + * Sets poultry_meat_including_sequestration + * + * @param float $poultry_meat_including_sequestration Poultry meat including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryMeatIncludingSequestration($poultry_meat_including_sequestration) + { + if (is_null($poultry_meat_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_meat_including_sequestration cannot be null'); + } + $this->container['poultry_meat_including_sequestration'] = $poultry_meat_including_sequestration; + + return $this; + } + + /** + * Gets poultry_meat_excluding_sequestration + * + * @return float + */ + public function getPoultryMeatExcludingSequestration() + { + return $this->container['poultry_meat_excluding_sequestration']; + } + + /** + * Sets poultry_meat_excluding_sequestration + * + * @param float $poultry_meat_excluding_sequestration Poultry meat excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setPoultryMeatExcludingSequestration($poultry_meat_excluding_sequestration) + { + if (is_null($poultry_meat_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_meat_excluding_sequestration cannot be null'); + } + $this->container['poultry_meat_excluding_sequestration'] = $poultry_meat_excluding_sequestration; + + return $this; + } + + /** + * Gets meat_produced_kg + * + * @return float + */ + public function getMeatProducedKg() + { + return $this->container['meat_produced_kg']; + } + + /** + * Sets meat_produced_kg + * + * @param float $meat_produced_kg Poultry meat produced in kg liveweight + * + * @return self + */ + public function setMeatProducedKg($meat_produced_kg) + { + if (is_null($meat_produced_kg)) { + throw new \InvalidArgumentException('non-nullable meat_produced_kg cannot be null'); + } + $this->container['meat_produced_kg'] = $meat_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInner.php new file mode 100644 index 00000000..33eb23c0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInner.php @@ -0,0 +1,635 @@ + + */ +class PostPoultry200ResponseIntermediateLayersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_intermediateLayers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostPoultry200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration', + 'intensities' => '\OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 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 scope1 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostPoultry200ResponseIntermediateLayersInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInnerIntensities.php new file mode 100644 index 00000000..9fddac27 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseIntermediateLayersInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostPoultry200ResponseIntermediateLayersInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_intermediateLayers_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'poultry_eggs_including_sequestration' => 'float', + 'poultry_eggs_excluding_sequestration' => 'float', + 'eggs_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'poultry_eggs_including_sequestration' => null, + 'poultry_eggs_excluding_sequestration' => null, + 'eggs_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'poultry_eggs_including_sequestration' => false, + 'poultry_eggs_excluding_sequestration' => false, + 'eggs_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'poultry_eggs_including_sequestration' => 'poultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'poultryEggsExcludingSequestration', + 'eggs_produced_kg' => 'eggsProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'poultry_eggs_including_sequestration' => 'setPoultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'setPoultryEggsExcludingSequestration', + 'eggs_produced_kg' => 'setEggsProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'poultry_eggs_including_sequestration' => 'getPoultryEggsIncludingSequestration', + 'poultry_eggs_excluding_sequestration' => 'getPoultryEggsExcludingSequestration', + 'eggs_produced_kg' => 'getEggsProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('poultry_eggs_including_sequestration', $data ?? [], null); + $this->setIfExists('poultry_eggs_excluding_sequestration', $data ?? [], null); + $this->setIfExists('eggs_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['poultry_eggs_including_sequestration'] === null) { + $invalidProperties[] = "'poultry_eggs_including_sequestration' can't be null"; + } + if ($this->container['poultry_eggs_excluding_sequestration'] === null) { + $invalidProperties[] = "'poultry_eggs_excluding_sequestration' can't be null"; + } + if ($this->container['eggs_produced_kg'] === null) { + $invalidProperties[] = "'eggs_produced_kg' 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 poultry_eggs_including_sequestration + * + * @return float + */ + public function getPoultryEggsIncludingSequestration() + { + return $this->container['poultry_eggs_including_sequestration']; + } + + /** + * Sets poultry_eggs_including_sequestration + * + * @param float $poultry_eggs_including_sequestration Poultry eggs including carbon sequestration, in kg-CO2e/kg eggs + * + * @return self + */ + public function setPoultryEggsIncludingSequestration($poultry_eggs_including_sequestration) + { + if (is_null($poultry_eggs_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_eggs_including_sequestration cannot be null'); + } + $this->container['poultry_eggs_including_sequestration'] = $poultry_eggs_including_sequestration; + + return $this; + } + + /** + * Gets poultry_eggs_excluding_sequestration + * + * @return float + */ + public function getPoultryEggsExcludingSequestration() + { + return $this->container['poultry_eggs_excluding_sequestration']; + } + + /** + * Sets poultry_eggs_excluding_sequestration + * + * @param float $poultry_eggs_excluding_sequestration Poultry eggs excluding carbon sequestration, in kg-CO2e/kg eggs + * + * @return self + */ + public function setPoultryEggsExcludingSequestration($poultry_eggs_excluding_sequestration) + { + if (is_null($poultry_eggs_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable poultry_eggs_excluding_sequestration cannot be null'); + } + $this->container['poultry_eggs_excluding_sequestration'] = $poultry_eggs_excluding_sequestration; + + return $this; + } + + /** + * Gets eggs_produced_kg + * + * @return float + */ + public function getEggsProducedKg() + { + return $this->container['eggs_produced_kg']; + } + + /** + * Sets eggs_produced_kg + * + * @param float $eggs_produced_kg Poultry eggs produced in kg + * + * @return self + */ + public function setEggsProducedKg($eggs_produced_kg) + { + if (is_null($eggs_produced_kg)) { + throw new \InvalidArgumentException('non-nullable eggs_produced_kg cannot be null'); + } + $this->container['eggs_produced_kg'] = $eggs_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseNet.php new file mode 100644 index 00000000..f99a8fcc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseNet.php @@ -0,0 +1,487 @@ + + */ +class PostPoultry200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'broilers' => 'float', + 'layers' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'broilers' => null, + 'layers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'broilers' => false, + 'layers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'broilers' => 'broilers', + 'layers' => 'layers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'broilers' => 'setBroilers', + 'layers' => 'setLayers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'broilers' => 'getBroilers', + 'layers' => 'getLayers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('broilers', $data ?? [], null); + $this->setIfExists('layers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['broilers'] === null) { + $invalidProperties[] = "'broilers' can't be null"; + } + if ($this->container['layers'] === null) { + $invalidProperties[] = "'layers' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total net emissions of this activity, in tonnes-CO2e/year + * + * @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 broilers + * + * @return float + */ + public function getBroilers() + { + return $this->container['broilers']; + } + + /** + * Sets broilers + * + * @param float $broilers Net emissions of broilers, in tonnes-CO2e/year + * + * @return self + */ + public function setBroilers($broilers) + { + if (is_null($broilers)) { + throw new \InvalidArgumentException('non-nullable broilers cannot be null'); + } + $this->container['broilers'] = $broilers; + + return $this; + } + + /** + * Gets layers + * + * @return float + */ + public function getLayers() + { + return $this->container['layers']; + } + + /** + * Sets layers + * + * @param float $layers Net emissions of layers, in tonnes-CO2e/year + * + * @return self + */ + public function setLayers($layers) + { + if (is_null($layers)) { + throw new \InvalidArgumentException('non-nullable layers cannot be null'); + } + $this->container['layers'] = $layers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope1.php new file mode 100644 index 00000000..ae2cbda3 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope1.php @@ -0,0 +1,784 @@ + + */ +class PostPoultry200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'manure_management_ch4' => 'float', + 'manure_management_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'manure_management_ch4' => null, + 'manure_management_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'manure_management_ch4' => false, + 'manure_management_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'manure_management_ch4' => 'manureManagementCH4', + 'manure_management_n2_o' => 'manureManagementN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'manure_management_ch4' => 'setManureManagementCh4', + 'manure_management_n2_o' => 'setManureManagementN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'manure_management_ch4' => 'getManureManagementCh4', + 'manure_management_n2_o' => 'getManureManagementN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('manure_management_ch4', $data ?? [], null); + $this->setIfExists('manure_management_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['manure_management_ch4'] === null) { + $invalidProperties[] = "'manure_management_ch4' can't be null"; + } + if ($this->container['manure_management_n2_o'] === null) { + $invalidProperties[] = "'manure_management_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets manure_management_ch4 + * + * @return float + */ + public function getManureManagementCh4() + { + return $this->container['manure_management_ch4']; + } + + /** + * Sets manure_management_ch4 + * + * @param float $manure_management_ch4 CH4 emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementCh4($manure_management_ch4) + { + if (is_null($manure_management_ch4)) { + throw new \InvalidArgumentException('non-nullable manure_management_ch4 cannot be null'); + } + $this->container['manure_management_ch4'] = $manure_management_ch4; + + return $this; + } + + /** + * Gets manure_management_n2_o + * + * @return float + */ + public function getManureManagementN2O() + { + return $this->container['manure_management_n2_o']; + } + + /** + * Sets manure_management_n2_o + * + * @param float $manure_management_n2_o N2O emissions from manure management, in tonnes-CO2e + * + * @return self + */ + public function setManureManagementN2O($manure_management_n2_o) + { + if (is_null($manure_management_n2_o)) { + throw new \InvalidArgumentException('non-nullable manure_management_n2_o cannot be null'); + } + $this->container['manure_management_n2_o'] = $manure_management_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope3.php new file mode 100644 index 00000000..278f067e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultry200ResponseScope3.php @@ -0,0 +1,636 @@ + + */ +class PostPoultry200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'purchased_feed' => 'float', + 'purchased_hay' => 'float', + 'purchased_livestock' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'purchased_feed' => null, + 'purchased_hay' => null, + 'purchased_livestock' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'purchased_feed' => false, + 'purchased_hay' => false, + 'purchased_livestock' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => 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 = [ + 'purchased_feed' => 'purchasedFeed', + 'purchased_hay' => 'purchasedHay', + 'purchased_livestock' => 'purchasedLivestock', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'purchased_feed' => 'setPurchasedFeed', + 'purchased_hay' => 'setPurchasedHay', + 'purchased_livestock' => 'setPurchasedLivestock', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'purchased_feed' => 'getPurchasedFeed', + 'purchased_hay' => 'getPurchasedHay', + 'purchased_livestock' => 'getPurchasedLivestock', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('purchased_feed', $data ?? [], null); + $this->setIfExists('purchased_hay', $data ?? [], null); + $this->setIfExists('purchased_livestock', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $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['purchased_feed'] === null) { + $invalidProperties[] = "'purchased_feed' can't be null"; + } + if ($this->container['purchased_hay'] === null) { + $invalidProperties[] = "'purchased_hay' can't be null"; + } + if ($this->container['purchased_livestock'] === null) { + $invalidProperties[] = "'purchased_livestock' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 purchased_feed + * + * @return float + */ + public function getPurchasedFeed() + { + return $this->container['purchased_feed']; + } + + /** + * Sets purchased_feed + * + * @param float $purchased_feed Emissions from purchased feed, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedFeed($purchased_feed) + { + if (is_null($purchased_feed)) { + throw new \InvalidArgumentException('non-nullable purchased_feed cannot be null'); + } + $this->container['purchased_feed'] = $purchased_feed; + + return $this; + } + + /** + * Gets purchased_hay + * + * @return float + */ + public function getPurchasedHay() + { + return $this->container['purchased_hay']; + } + + /** + * Sets purchased_hay + * + * @param float $purchased_hay Emissions from purchased hay, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedHay($purchased_hay) + { + if (is_null($purchased_hay)) { + throw new \InvalidArgumentException('non-nullable purchased_hay cannot be null'); + } + $this->container['purchased_hay'] = $purchased_hay; + + return $this; + } + + /** + * Gets purchased_livestock + * + * @return float + */ + public function getPurchasedLivestock() + { + return $this->container['purchased_livestock']; + } + + /** + * Sets purchased_livestock + * + * @param float $purchased_livestock Emissions from purchased livestock, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedLivestock($purchased_livestock) + { + if (is_null($purchased_livestock)) { + throw new \InvalidArgumentException('non-nullable purchased_livestock cannot be null'); + } + $this->container['purchased_livestock'] = $purchased_livestock; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequest.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequest.php new file mode 100644 index 00000000..9b7c23d2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequest.php @@ -0,0 +1,647 @@ + + */ +class PostPoultryRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'north_of_tropic_of_capricorn' => 'bool', + 'rainfall_above600' => 'bool', + 'broilers' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInner[]', + 'layers' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostPoultryRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'north_of_tropic_of_capricorn' => null, + 'rainfall_above600' => null, + 'broilers' => null, + 'layers' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'north_of_tropic_of_capricorn' => false, + 'rainfall_above600' => false, + 'broilers' => false, + 'layers' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'north_of_tropic_of_capricorn' => 'northOfTropicOfCapricorn', + 'rainfall_above600' => 'rainfallAbove600', + 'broilers' => 'broilers', + 'layers' => 'layers', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'north_of_tropic_of_capricorn' => 'setNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'setRainfallAbove600', + 'broilers' => 'setBroilers', + 'layers' => 'setLayers', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'north_of_tropic_of_capricorn' => 'getNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'getRainfallAbove600', + 'broilers' => 'getBroilers', + 'layers' => 'getLayers', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('north_of_tropic_of_capricorn', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('broilers', $data ?? [], null); + $this->setIfExists('layers', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['north_of_tropic_of_capricorn'] === null) { + $invalidProperties[] = "'north_of_tropic_of_capricorn' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['broilers'] === null) { + $invalidProperties[] = "'broilers' can't be null"; + } + if ($this->container['layers'] === null) { + $invalidProperties[] = "'layers' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets north_of_tropic_of_capricorn + * + * @return bool + */ + public function getNorthOfTropicOfCapricorn() + { + return $this->container['north_of_tropic_of_capricorn']; + } + + /** + * Sets north_of_tropic_of_capricorn + * + * @param bool $north_of_tropic_of_capricorn Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude + * + * @return self + */ + public function setNorthOfTropicOfCapricorn($north_of_tropic_of_capricorn) + { + if (is_null($north_of_tropic_of_capricorn)) { + throw new \InvalidArgumentException('non-nullable north_of_tropic_of_capricorn cannot be null'); + } + $this->container['north_of_tropic_of_capricorn'] = $north_of_tropic_of_capricorn; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets broilers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInner[] + */ + public function getBroilers() + { + return $this->container['broilers']; + } + + /** + * Sets broilers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInner[] $broilers broilers + * + * @return self + */ + public function setBroilers($broilers) + { + if (is_null($broilers)) { + throw new \InvalidArgumentException('non-nullable broilers cannot be null'); + } + $this->container['broilers'] = $broilers; + + return $this; + } + + /** + * Gets layers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInner[] + */ + public function getLayers() + { + return $this->container['layers']; + } + + /** + * Sets layers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInner[] $layers layers + * + * @return self + */ + public function setLayers($layers) + { + if (is_null($layers)) { + throw new \InvalidArgumentException('non-nullable layers cannot be null'); + } + $this->container['layers'] = $layers; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostPoultryRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostPoultryRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInner.php new file mode 100644 index 00000000..74062431 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInner.php @@ -0,0 +1,1163 @@ + + */ +class PostPoultryRequestBroilersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'groups' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInner[]', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'hay' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'manure_waste_allocation' => 'float', + 'waste_handled_drylot_or_storage' => 'float', + 'litter_recycled' => 'float', + 'litter_recycle_frequency' => 'float', + 'purchased_free_range' => 'float', + 'meat_chicken_growers_purchases' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases', + 'meat_chicken_layers_purchases' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases', + 'meat_other_purchases' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatOtherPurchases', + 'sales' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerSalesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'groups' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'hay' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'manure_waste_allocation' => null, + 'waste_handled_drylot_or_storage' => null, + 'litter_recycled' => null, + 'litter_recycle_frequency' => null, + 'purchased_free_range' => null, + 'meat_chicken_growers_purchases' => null, + 'meat_chicken_layers_purchases' => null, + 'meat_other_purchases' => null, + 'sales' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'groups' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'hay' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'manure_waste_allocation' => false, + 'waste_handled_drylot_or_storage' => false, + 'litter_recycled' => false, + 'litter_recycle_frequency' => false, + 'purchased_free_range' => false, + 'meat_chicken_growers_purchases' => false, + 'meat_chicken_layers_purchases' => false, + 'meat_other_purchases' => false, + 'sales' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'groups' => 'groups', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'hay' => 'hay', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'manure_waste_allocation' => 'manureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'wasteHandledDrylotOrStorage', + 'litter_recycled' => 'litterRecycled', + 'litter_recycle_frequency' => 'litterRecycleFrequency', + 'purchased_free_range' => 'purchasedFreeRange', + 'meat_chicken_growers_purchases' => 'meatChickenGrowersPurchases', + 'meat_chicken_layers_purchases' => 'meatChickenLayersPurchases', + 'meat_other_purchases' => 'meatOtherPurchases', + 'sales' => 'sales' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'groups' => 'setGroups', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'hay' => 'setHay', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'manure_waste_allocation' => 'setManureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'setWasteHandledDrylotOrStorage', + 'litter_recycled' => 'setLitterRecycled', + 'litter_recycle_frequency' => 'setLitterRecycleFrequency', + 'purchased_free_range' => 'setPurchasedFreeRange', + 'meat_chicken_growers_purchases' => 'setMeatChickenGrowersPurchases', + 'meat_chicken_layers_purchases' => 'setMeatChickenLayersPurchases', + 'meat_other_purchases' => 'setMeatOtherPurchases', + 'sales' => 'setSales' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'groups' => 'getGroups', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'hay' => 'getHay', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'manure_waste_allocation' => 'getManureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'getWasteHandledDrylotOrStorage', + 'litter_recycled' => 'getLitterRecycled', + 'litter_recycle_frequency' => 'getLitterRecycleFrequency', + 'purchased_free_range' => 'getPurchasedFreeRange', + 'meat_chicken_growers_purchases' => 'getMeatChickenGrowersPurchases', + 'meat_chicken_layers_purchases' => 'getMeatChickenLayersPurchases', + 'meat_other_purchases' => 'getMeatOtherPurchases', + 'sales' => 'getSales' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('groups', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('hay', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('manure_waste_allocation', $data ?? [], null); + $this->setIfExists('waste_handled_drylot_or_storage', $data ?? [], null); + $this->setIfExists('litter_recycled', $data ?? [], null); + $this->setIfExists('litter_recycle_frequency', $data ?? [], null); + $this->setIfExists('purchased_free_range', $data ?? [], null); + $this->setIfExists('meat_chicken_growers_purchases', $data ?? [], null); + $this->setIfExists('meat_chicken_layers_purchases', $data ?? [], null); + $this->setIfExists('meat_other_purchases', $data ?? [], null); + $this->setIfExists('sales', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['groups'] === null) { + $invalidProperties[] = "'groups' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['hay'] === null) { + $invalidProperties[] = "'hay' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['manure_waste_allocation'] === null) { + $invalidProperties[] = "'manure_waste_allocation' can't be null"; + } + if ($this->container['waste_handled_drylot_or_storage'] === null) { + $invalidProperties[] = "'waste_handled_drylot_or_storage' can't be null"; + } + if ($this->container['litter_recycled'] === null) { + $invalidProperties[] = "'litter_recycled' can't be null"; + } + if ($this->container['litter_recycle_frequency'] === null) { + $invalidProperties[] = "'litter_recycle_frequency' can't be null"; + } + if ($this->container['purchased_free_range'] === null) { + $invalidProperties[] = "'purchased_free_range' can't be null"; + } + if ($this->container['meat_chicken_growers_purchases'] === null) { + $invalidProperties[] = "'meat_chicken_growers_purchases' can't be null"; + } + if ($this->container['meat_chicken_layers_purchases'] === null) { + $invalidProperties[] = "'meat_chicken_layers_purchases' can't be null"; + } + if ($this->container['meat_other_purchases'] === null) { + $invalidProperties[] = "'meat_other_purchases' can't be null"; + } + if ($this->container['sales'] === null) { + $invalidProperties[] = "'sales' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 groups + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInner[] + */ + public function getGroups() + { + return $this->container['groups']; + } + + /** + * Sets groups + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInner[] $groups groups + * + * @return self + */ + public function setGroups($groups) + { + if (is_null($groups)) { + throw new \InvalidArgumentException('non-nullable groups cannot be null'); + } + $this->container['groups'] = $groups; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPoultryRequestBroilersInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPoultryRequestBroilersInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets hay + * + * @return float + */ + public function getHay() + { + return $this->container['hay']; + } + + /** + * Sets hay + * + * @param float $hay Hay purchased in tonnes + * + * @return self + */ + public function setHay($hay) + { + if (is_null($hay)) { + throw new \InvalidArgumentException('non-nullable hay cannot be null'); + } + $this->container['hay'] = $hay; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets manure_waste_allocation + * + * @return float + */ + public function getManureWasteAllocation() + { + return $this->container['manure_waste_allocation']; + } + + /** + * Sets manure_waste_allocation + * + * @param float $manure_waste_allocation Fraction allocation of manure waste, from 0 to 1. Note: only for pasture range, paddock and free range systems + * + * @return self + */ + public function setManureWasteAllocation($manure_waste_allocation) + { + if (is_null($manure_waste_allocation)) { + throw new \InvalidArgumentException('non-nullable manure_waste_allocation cannot be null'); + } + $this->container['manure_waste_allocation'] = $manure_waste_allocation; + + return $this; + } + + /** + * Gets waste_handled_drylot_or_storage + * + * @return float + */ + public function getWasteHandledDrylotOrStorage() + { + return $this->container['waste_handled_drylot_or_storage']; + } + + /** + * Sets waste_handled_drylot_or_storage + * + * @param float $waste_handled_drylot_or_storage Fraction of waste handled through dryland and solid storage, from 0 to 1 + * + * @return self + */ + public function setWasteHandledDrylotOrStorage($waste_handled_drylot_or_storage) + { + if (is_null($waste_handled_drylot_or_storage)) { + throw new \InvalidArgumentException('non-nullable waste_handled_drylot_or_storage cannot be null'); + } + $this->container['waste_handled_drylot_or_storage'] = $waste_handled_drylot_or_storage; + + return $this; + } + + /** + * Gets litter_recycled + * + * @return float + */ + public function getLitterRecycled() + { + return $this->container['litter_recycled']; + } + + /** + * Sets litter_recycled + * + * @param float $litter_recycled Fraction of litter recycled, from 0 to 1 + * + * @return self + */ + public function setLitterRecycled($litter_recycled) + { + if (is_null($litter_recycled)) { + throw new \InvalidArgumentException('non-nullable litter_recycled cannot be null'); + } + $this->container['litter_recycled'] = $litter_recycled; + + return $this; + } + + /** + * Gets litter_recycle_frequency + * + * @return float + */ + public function getLitterRecycleFrequency() + { + return $this->container['litter_recycle_frequency']; + } + + /** + * Sets litter_recycle_frequency + * + * @param float $litter_recycle_frequency Number of litter cycles per year + * + * @return self + */ + public function setLitterRecycleFrequency($litter_recycle_frequency) + { + if (is_null($litter_recycle_frequency)) { + throw new \InvalidArgumentException('non-nullable litter_recycle_frequency cannot be null'); + } + $this->container['litter_recycle_frequency'] = $litter_recycle_frequency; + + return $this; + } + + /** + * Gets purchased_free_range + * + * @return float + */ + public function getPurchasedFreeRange() + { + return $this->container['purchased_free_range']; + } + + /** + * Sets purchased_free_range + * + * @param float $purchased_free_range Fraction of chickens purchased that are free range. Note: fraction of chickens purchased that are conventional is `1 - purchasedFreeRange` + * + * @return self + */ + public function setPurchasedFreeRange($purchased_free_range) + { + if (is_null($purchased_free_range)) { + throw new \InvalidArgumentException('non-nullable purchased_free_range cannot be null'); + } + $this->container['purchased_free_range'] = $purchased_free_range; + + return $this; + } + + /** + * Gets meat_chicken_growers_purchases + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases + */ + public function getMeatChickenGrowersPurchases() + { + return $this->container['meat_chicken_growers_purchases']; + } + + /** + * Sets meat_chicken_growers_purchases + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases $meat_chicken_growers_purchases meat_chicken_growers_purchases + * + * @return self + */ + public function setMeatChickenGrowersPurchases($meat_chicken_growers_purchases) + { + if (is_null($meat_chicken_growers_purchases)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_growers_purchases cannot be null'); + } + $this->container['meat_chicken_growers_purchases'] = $meat_chicken_growers_purchases; + + return $this; + } + + /** + * Gets meat_chicken_layers_purchases + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases + */ + public function getMeatChickenLayersPurchases() + { + return $this->container['meat_chicken_layers_purchases']; + } + + /** + * Sets meat_chicken_layers_purchases + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases $meat_chicken_layers_purchases meat_chicken_layers_purchases + * + * @return self + */ + public function setMeatChickenLayersPurchases($meat_chicken_layers_purchases) + { + if (is_null($meat_chicken_layers_purchases)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers_purchases cannot be null'); + } + $this->container['meat_chicken_layers_purchases'] = $meat_chicken_layers_purchases; + + return $this; + } + + /** + * Gets meat_other_purchases + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatOtherPurchases + */ + public function getMeatOtherPurchases() + { + return $this->container['meat_other_purchases']; + } + + /** + * Sets meat_other_purchases + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatOtherPurchases $meat_other_purchases meat_other_purchases + * + * @return self + */ + public function setMeatOtherPurchases($meat_other_purchases) + { + if (is_null($meat_other_purchases)) { + throw new \InvalidArgumentException('non-nullable meat_other_purchases cannot be null'); + } + $this->container['meat_other_purchases'] = $meat_other_purchases; + + return $this; + } + + /** + * Gets sales + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerSalesInner[] + */ + public function getSales() + { + return $this->container['sales']; + } + + /** + * Sets sales + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerSalesInner[] $sales Broiler sales + * + * @return self + */ + public function setSales($sales) + { + if (is_null($sales)) { + throw new \InvalidArgumentException('non-nullable sales cannot be null'); + } + $this->container['sales'] = $sales; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInner.php new file mode 100644 index 00000000..957e7765 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInner.php @@ -0,0 +1,599 @@ + + */ +class PostPoultryRequestBroilersInnerGroupsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_groups_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'meat_chicken_growers' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers', + 'meat_chicken_layers' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers', + 'meat_other' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers', + 'feed' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[]', + 'custom_feed_purchased' => 'float', + 'custom_feed_emission_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'meat_chicken_growers' => null, + 'meat_chicken_layers' => null, + 'meat_other' => null, + 'feed' => null, + 'custom_feed_purchased' => null, + 'custom_feed_emission_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'meat_chicken_growers' => false, + 'meat_chicken_layers' => false, + 'meat_other' => false, + 'feed' => false, + 'custom_feed_purchased' => false, + 'custom_feed_emission_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'meat_chicken_growers' => 'meatChickenGrowers', + 'meat_chicken_layers' => 'meatChickenLayers', + 'meat_other' => 'meatOther', + 'feed' => 'feed', + 'custom_feed_purchased' => 'customFeedPurchased', + 'custom_feed_emission_intensity' => 'customFeedEmissionIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'meat_chicken_growers' => 'setMeatChickenGrowers', + 'meat_chicken_layers' => 'setMeatChickenLayers', + 'meat_other' => 'setMeatOther', + 'feed' => 'setFeed', + 'custom_feed_purchased' => 'setCustomFeedPurchased', + 'custom_feed_emission_intensity' => 'setCustomFeedEmissionIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'meat_chicken_growers' => 'getMeatChickenGrowers', + 'meat_chicken_layers' => 'getMeatChickenLayers', + 'meat_other' => 'getMeatOther', + 'feed' => 'getFeed', + 'custom_feed_purchased' => 'getCustomFeedPurchased', + 'custom_feed_emission_intensity' => 'getCustomFeedEmissionIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('meat_chicken_growers', $data ?? [], null); + $this->setIfExists('meat_chicken_layers', $data ?? [], null); + $this->setIfExists('meat_other', $data ?? [], null); + $this->setIfExists('feed', $data ?? [], null); + $this->setIfExists('custom_feed_purchased', $data ?? [], null); + $this->setIfExists('custom_feed_emission_intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['meat_chicken_growers'] === null) { + $invalidProperties[] = "'meat_chicken_growers' can't be null"; + } + if ($this->container['meat_chicken_layers'] === null) { + $invalidProperties[] = "'meat_chicken_layers' can't be null"; + } + if ($this->container['meat_other'] === null) { + $invalidProperties[] = "'meat_other' can't be null"; + } + if ($this->container['feed'] === null) { + $invalidProperties[] = "'feed' can't be null"; + } + if ($this->container['custom_feed_purchased'] === null) { + $invalidProperties[] = "'custom_feed_purchased' can't be null"; + } + if ($this->container['custom_feed_emission_intensity'] === null) { + $invalidProperties[] = "'custom_feed_emission_intensity' 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 meat_chicken_growers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers + */ + public function getMeatChickenGrowers() + { + return $this->container['meat_chicken_growers']; + } + + /** + * Sets meat_chicken_growers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers $meat_chicken_growers meat_chicken_growers + * + * @return self + */ + public function setMeatChickenGrowers($meat_chicken_growers) + { + if (is_null($meat_chicken_growers)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_growers cannot be null'); + } + $this->container['meat_chicken_growers'] = $meat_chicken_growers; + + return $this; + } + + /** + * Gets meat_chicken_layers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers + */ + public function getMeatChickenLayers() + { + return $this->container['meat_chicken_layers']; + } + + /** + * Sets meat_chicken_layers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers $meat_chicken_layers meat_chicken_layers + * + * @return self + */ + public function setMeatChickenLayers($meat_chicken_layers) + { + if (is_null($meat_chicken_layers)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers cannot be null'); + } + $this->container['meat_chicken_layers'] = $meat_chicken_layers; + + return $this; + } + + /** + * Gets meat_other + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers + */ + public function getMeatOther() + { + return $this->container['meat_other']; + } + + /** + * Sets meat_other + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers $meat_other meat_other + * + * @return self + */ + public function setMeatOther($meat_other) + { + if (is_null($meat_other)) { + throw new \InvalidArgumentException('non-nullable meat_other cannot be null'); + } + $this->container['meat_other'] = $meat_other; + + return $this; + } + + /** + * Gets feed + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[] + */ + public function getFeed() + { + return $this->container['feed']; + } + + /** + * Sets feed + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[] $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 custom_feed_purchased + * + * @return float + */ + public function getCustomFeedPurchased() + { + return $this->container['custom_feed_purchased']; + } + + /** + * Sets custom_feed_purchased + * + * @param float $custom_feed_purchased Custom feed purchased, in tonnes + * + * @return self + */ + public function setCustomFeedPurchased($custom_feed_purchased) + { + if (is_null($custom_feed_purchased)) { + throw new \InvalidArgumentException('non-nullable custom_feed_purchased cannot be null'); + } + $this->container['custom_feed_purchased'] = $custom_feed_purchased; + + return $this; + } + + /** + * Gets custom_feed_emission_intensity + * + * @return float + */ + public function getCustomFeedEmissionIntensity() + { + return $this->container['custom_feed_emission_intensity']; + } + + /** + * Sets custom_feed_emission_intensity + * + * @param float $custom_feed_emission_intensity Emissions intensity of custom feed in GHG (kg CO2-e/kg input) + * + * @return self + */ + public function setCustomFeedEmissionIntensity($custom_feed_emission_intensity) + { + if (is_null($custom_feed_emission_intensity)) { + throw new \InvalidArgumentException('non-nullable custom_feed_emission_intensity cannot be null'); + } + $this->container['custom_feed_emission_intensity'] = $custom_feed_emission_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.php new file mode 100644 index 00000000..5a447b41 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.php @@ -0,0 +1,525 @@ + + */ +class PostPoultryRequestBroilersInnerGroupsInnerFeedInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_groups_inner_feed_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'ingredients' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients', + 'feed_purchased' => 'float', + 'additional_ingredient' => 'float', + 'emission_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'ingredients' => null, + 'feed_purchased' => null, + 'additional_ingredient' => null, + 'emission_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'ingredients' => false, + 'feed_purchased' => false, + 'additional_ingredient' => false, + 'emission_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'ingredients' => 'ingredients', + 'feed_purchased' => 'feedPurchased', + 'additional_ingredient' => 'additionalIngredient', + 'emission_intensity' => 'emissionIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'ingredients' => 'setIngredients', + 'feed_purchased' => 'setFeedPurchased', + 'additional_ingredient' => 'setAdditionalIngredient', + 'emission_intensity' => 'setEmissionIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'ingredients' => 'getIngredients', + 'feed_purchased' => 'getFeedPurchased', + 'additional_ingredient' => 'getAdditionalIngredient', + 'emission_intensity' => 'getEmissionIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('ingredients', $data ?? [], null); + $this->setIfExists('feed_purchased', $data ?? [], null); + $this->setIfExists('additional_ingredient', $data ?? [], null); + $this->setIfExists('emission_intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['ingredients'] === null) { + $invalidProperties[] = "'ingredients' can't be null"; + } + if ($this->container['feed_purchased'] === null) { + $invalidProperties[] = "'feed_purchased' can't be null"; + } + if ($this->container['additional_ingredient'] === null) { + $invalidProperties[] = "'additional_ingredient' can't be null"; + } + if ($this->container['emission_intensity'] === null) { + $invalidProperties[] = "'emission_intensity' 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 ingredients + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients + */ + public function getIngredients() + { + return $this->container['ingredients']; + } + + /** + * Sets ingredients + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients $ingredients ingredients + * + * @return self + */ + public function setIngredients($ingredients) + { + if (is_null($ingredients)) { + throw new \InvalidArgumentException('non-nullable ingredients cannot be null'); + } + $this->container['ingredients'] = $ingredients; + + return $this; + } + + /** + * Gets feed_purchased + * + * @return float + */ + public function getFeedPurchased() + { + return $this->container['feed_purchased']; + } + + /** + * Sets feed_purchased + * + * @param float $feed_purchased Feed purchased, in tonnes + * + * @return self + */ + public function setFeedPurchased($feed_purchased) + { + if (is_null($feed_purchased)) { + throw new \InvalidArgumentException('non-nullable feed_purchased cannot be null'); + } + $this->container['feed_purchased'] = $feed_purchased; + + return $this; + } + + /** + * Gets additional_ingredient + * + * @return float + */ + public function getAdditionalIngredient() + { + return $this->container['additional_ingredient']; + } + + /** + * Sets additional_ingredient + * + * @param float $additional_ingredient Fraction of additional ingredients in feed mix, from 0 to 1 + * + * @return self + */ + public function setAdditionalIngredient($additional_ingredient) + { + if (is_null($additional_ingredient)) { + throw new \InvalidArgumentException('non-nullable additional_ingredient cannot be null'); + } + $this->container['additional_ingredient'] = $additional_ingredient; + + return $this; + } + + /** + * Gets emission_intensity + * + * @return float + */ + public function getEmissionIntensity() + { + return $this->container['emission_intensity']; + } + + /** + * Sets emission_intensity + * + * @param float $emission_intensity Emissions intensity of feed product in GHG (kg CO2-e/kg input) + * + * @return self + */ + public function setEmissionIntensity($emission_intensity) + { + if (is_null($emission_intensity)) { + throw new \InvalidArgumentException('non-nullable emission_intensity cannot be null'); + } + $this->container['emission_intensity'] = $emission_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.php new file mode 100644 index 00000000..7170cd31 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.php @@ -0,0 +1,547 @@ + + */ +class PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'wheat' => 'float', + 'barley' => 'float', + 'sorghum' => 'float', + 'soybean' => 'float', + 'millrun' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'wheat' => null, + 'barley' => null, + 'sorghum' => null, + 'soybean' => null, + 'millrun' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'wheat' => false, + 'barley' => false, + 'sorghum' => false, + 'soybean' => false, + 'millrun' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'wheat' => 'wheat', + 'barley' => 'barley', + 'sorghum' => 'sorghum', + 'soybean' => 'soybean', + 'millrun' => 'millrun' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'wheat' => 'setWheat', + 'barley' => 'setBarley', + 'sorghum' => 'setSorghum', + 'soybean' => 'setSoybean', + 'millrun' => 'setMillrun' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'wheat' => 'getWheat', + 'barley' => 'getBarley', + 'sorghum' => 'getSorghum', + 'soybean' => 'getSoybean', + 'millrun' => 'getMillrun' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('wheat', $data ?? [], null); + $this->setIfExists('barley', $data ?? [], null); + $this->setIfExists('sorghum', $data ?? [], null); + $this->setIfExists('soybean', $data ?? [], null); + $this->setIfExists('millrun', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $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 wheat + * + * @return float|null + */ + public function getWheat() + { + return $this->container['wheat']; + } + + /** + * Sets wheat + * + * @param float|null $wheat wheat + * + * @return self + */ + public function setWheat($wheat) + { + if (is_null($wheat)) { + throw new \InvalidArgumentException('non-nullable wheat cannot be null'); + } + $this->container['wheat'] = $wheat; + + return $this; + } + + /** + * Gets barley + * + * @return float|null + */ + public function getBarley() + { + return $this->container['barley']; + } + + /** + * Sets barley + * + * @param float|null $barley barley + * + * @return self + */ + public function setBarley($barley) + { + if (is_null($barley)) { + throw new \InvalidArgumentException('non-nullable barley cannot be null'); + } + $this->container['barley'] = $barley; + + return $this; + } + + /** + * Gets sorghum + * + * @return float|null + */ + public function getSorghum() + { + return $this->container['sorghum']; + } + + /** + * Sets sorghum + * + * @param float|null $sorghum sorghum + * + * @return self + */ + public function setSorghum($sorghum) + { + if (is_null($sorghum)) { + throw new \InvalidArgumentException('non-nullable sorghum cannot be null'); + } + $this->container['sorghum'] = $sorghum; + + return $this; + } + + /** + * Gets soybean + * + * @return float|null + */ + public function getSoybean() + { + return $this->container['soybean']; + } + + /** + * Sets soybean + * + * @param float|null $soybean soybean + * + * @return self + */ + public function setSoybean($soybean) + { + if (is_null($soybean)) { + throw new \InvalidArgumentException('non-nullable soybean cannot be null'); + } + $this->container['soybean'] = $soybean; + + return $this; + } + + /** + * Gets millrun + * + * @return float|null + */ + public function getMillrun() + { + return $this->container['millrun']; + } + + /** + * Sets millrun + * + * @param float|null $millrun millrun + * + * @return self + */ + public function setMillrun($millrun) + { + if (is_null($millrun)) { + throw new \InvalidArgumentException('non-nullable millrun cannot be null'); + } + $this->container['millrun'] = $millrun; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.php new file mode 100644 index 00000000..f477bd7b --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.php @@ -0,0 +1,732 @@ + + */ +class PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_groups_inner_meatChickenGrowers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'birds' => 'float', + 'average_stay_length50' => 'float', + 'liveweight50' => 'float', + 'average_stay_length100' => 'float', + 'liveweight100' => 'float', + 'dry_matter_intake' => 'float', + 'dry_matter_digestibility' => 'float', + 'crude_protein' => 'float', + 'manure_ash' => 'float', + 'nitrogen_retention_rate' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'birds' => null, + 'average_stay_length50' => null, + 'liveweight50' => null, + 'average_stay_length100' => null, + 'liveweight100' => null, + 'dry_matter_intake' => null, + 'dry_matter_digestibility' => null, + 'crude_protein' => null, + 'manure_ash' => null, + 'nitrogen_retention_rate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'birds' => false, + 'average_stay_length50' => false, + 'liveweight50' => false, + 'average_stay_length100' => false, + 'liveweight100' => false, + 'dry_matter_intake' => false, + 'dry_matter_digestibility' => false, + 'crude_protein' => false, + 'manure_ash' => false, + 'nitrogen_retention_rate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'birds' => 'birds', + 'average_stay_length50' => 'averageStayLength50', + 'liveweight50' => 'liveweight50', + 'average_stay_length100' => 'averageStayLength100', + 'liveweight100' => 'liveweight100', + 'dry_matter_intake' => 'dryMatterIntake', + 'dry_matter_digestibility' => 'dryMatterDigestibility', + 'crude_protein' => 'crudeProtein', + 'manure_ash' => 'manureAsh', + 'nitrogen_retention_rate' => 'nitrogenRetentionRate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'birds' => 'setBirds', + 'average_stay_length50' => 'setAverageStayLength50', + 'liveweight50' => 'setLiveweight50', + 'average_stay_length100' => 'setAverageStayLength100', + 'liveweight100' => 'setLiveweight100', + 'dry_matter_intake' => 'setDryMatterIntake', + 'dry_matter_digestibility' => 'setDryMatterDigestibility', + 'crude_protein' => 'setCrudeProtein', + 'manure_ash' => 'setManureAsh', + 'nitrogen_retention_rate' => 'setNitrogenRetentionRate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'birds' => 'getBirds', + 'average_stay_length50' => 'getAverageStayLength50', + 'liveweight50' => 'getLiveweight50', + 'average_stay_length100' => 'getAverageStayLength100', + 'liveweight100' => 'getLiveweight100', + 'dry_matter_intake' => 'getDryMatterIntake', + 'dry_matter_digestibility' => 'getDryMatterDigestibility', + 'crude_protein' => 'getCrudeProtein', + 'manure_ash' => 'getManureAsh', + 'nitrogen_retention_rate' => 'getNitrogenRetentionRate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('birds', $data ?? [], null); + $this->setIfExists('average_stay_length50', $data ?? [], null); + $this->setIfExists('liveweight50', $data ?? [], null); + $this->setIfExists('average_stay_length100', $data ?? [], null); + $this->setIfExists('liveweight100', $data ?? [], null); + $this->setIfExists('dry_matter_intake', $data ?? [], null); + $this->setIfExists('dry_matter_digestibility', $data ?? [], null); + $this->setIfExists('crude_protein', $data ?? [], null); + $this->setIfExists('manure_ash', $data ?? [], null); + $this->setIfExists('nitrogen_retention_rate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['birds'] === null) { + $invalidProperties[] = "'birds' can't be null"; + } + if ($this->container['average_stay_length50'] === null) { + $invalidProperties[] = "'average_stay_length50' can't be null"; + } + if ($this->container['liveweight50'] === null) { + $invalidProperties[] = "'liveweight50' can't be null"; + } + if ($this->container['average_stay_length100'] === null) { + $invalidProperties[] = "'average_stay_length100' can't be null"; + } + if ($this->container['liveweight100'] === null) { + $invalidProperties[] = "'liveweight100' 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 birds + * + * @return float + */ + public function getBirds() + { + return $this->container['birds']; + } + + /** + * Sets birds + * + * @param float $birds Total number of birds/head + * + * @return self + */ + public function setBirds($birds) + { + if (is_null($birds)) { + throw new \InvalidArgumentException('non-nullable birds cannot be null'); + } + $this->container['birds'] = $birds; + + return $this; + } + + /** + * Gets average_stay_length50 + * + * @return float + */ + public function getAverageStayLength50() + { + return $this->container['average_stay_length50']; + } + + /** + * Sets average_stay_length50 + * + * @param float $average_stay_length50 Average length of stay until 50% of the flock is depleted, in days + * + * @return self + */ + public function setAverageStayLength50($average_stay_length50) + { + if (is_null($average_stay_length50)) { + throw new \InvalidArgumentException('non-nullable average_stay_length50 cannot be null'); + } + $this->container['average_stay_length50'] = $average_stay_length50; + + return $this; + } + + /** + * Gets liveweight50 + * + * @return float + */ + public function getLiveweight50() + { + return $this->container['liveweight50']; + } + + /** + * Sets liveweight50 + * + * @param float $liveweight50 Average liveweight during the 50% depletion period, in kg + * + * @return self + */ + public function setLiveweight50($liveweight50) + { + if (is_null($liveweight50)) { + throw new \InvalidArgumentException('non-nullable liveweight50 cannot be null'); + } + $this->container['liveweight50'] = $liveweight50; + + return $this; + } + + /** + * Gets average_stay_length100 + * + * @return float + */ + public function getAverageStayLength100() + { + return $this->container['average_stay_length100']; + } + + /** + * Sets average_stay_length100 + * + * @param float $average_stay_length100 Average length of stay until 100% of the flock is depleted, in days + * + * @return self + */ + public function setAverageStayLength100($average_stay_length100) + { + if (is_null($average_stay_length100)) { + throw new \InvalidArgumentException('non-nullable average_stay_length100 cannot be null'); + } + $this->container['average_stay_length100'] = $average_stay_length100; + + return $this; + } + + /** + * Gets liveweight100 + * + * @return float + */ + public function getLiveweight100() + { + return $this->container['liveweight100']; + } + + /** + * Sets liveweight100 + * + * @param float $liveweight100 Average liveweight during the 100% depletion period, in kg + * + * @return self + */ + public function setLiveweight100($liveweight100) + { + if (is_null($liveweight100)) { + throw new \InvalidArgumentException('non-nullable liveweight100 cannot be null'); + } + $this->container['liveweight100'] = $liveweight100; + + return $this; + } + + /** + * Gets dry_matter_intake + * + * @return float|null + */ + public function getDryMatterIntake() + { + return $this->container['dry_matter_intake']; + } + + /** + * Sets dry_matter_intake + * + * @param float|null $dry_matter_intake Dry matter intake, in kg/head/day + * + * @return self + */ + public function setDryMatterIntake($dry_matter_intake) + { + if (is_null($dry_matter_intake)) { + throw new \InvalidArgumentException('non-nullable dry_matter_intake cannot be null'); + } + $this->container['dry_matter_intake'] = $dry_matter_intake; + + return $this; + } + + /** + * Gets dry_matter_digestibility + * + * @return float|null + */ + public function getDryMatterDigestibility() + { + return $this->container['dry_matter_digestibility']; + } + + /** + * Sets dry_matter_digestibility + * + * @param float|null $dry_matter_digestibility Dry matter digestibility fraction, from 0 to 1 + * + * @return self + */ + public function setDryMatterDigestibility($dry_matter_digestibility) + { + if (is_null($dry_matter_digestibility)) { + throw new \InvalidArgumentException('non-nullable dry_matter_digestibility cannot be null'); + } + $this->container['dry_matter_digestibility'] = $dry_matter_digestibility; + + return $this; + } + + /** + * Gets crude_protein + * + * @return float|null + */ + public function getCrudeProtein() + { + return $this->container['crude_protein']; + } + + /** + * Sets crude_protein + * + * @param float|null $crude_protein Crude protein fraction, from 0 to 1 + * + * @return self + */ + public function setCrudeProtein($crude_protein) + { + if (is_null($crude_protein)) { + throw new \InvalidArgumentException('non-nullable crude_protein cannot be null'); + } + $this->container['crude_protein'] = $crude_protein; + + return $this; + } + + /** + * Gets manure_ash + * + * @return float|null + */ + public function getManureAsh() + { + return $this->container['manure_ash']; + } + + /** + * Sets manure_ash + * + * @param float|null $manure_ash Manure ash fraction, from 0 to 1 + * + * @return self + */ + public function setManureAsh($manure_ash) + { + if (is_null($manure_ash)) { + throw new \InvalidArgumentException('non-nullable manure_ash cannot be null'); + } + $this->container['manure_ash'] = $manure_ash; + + return $this; + } + + /** + * Gets nitrogen_retention_rate + * + * @return float|null + */ + public function getNitrogenRetentionRate() + { + return $this->container['nitrogen_retention_rate']; + } + + /** + * Sets nitrogen_retention_rate + * + * @param float|null $nitrogen_retention_rate Nitrogen retention rate fraction, from 0 to 1 + * + * @return self + */ + public function setNitrogenRetentionRate($nitrogen_retention_rate) + { + if (is_null($nitrogen_retention_rate)) { + throw new \InvalidArgumentException('non-nullable nitrogen_retention_rate cannot be null'); + } + $this->container['nitrogen_retention_rate'] = $nitrogen_retention_rate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.php new file mode 100644 index 00000000..90866ee8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_meatChickenGrowersPurchases'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_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 = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.php new file mode 100644 index 00000000..8d8ee8b5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestBroilersInnerMeatChickenLayersPurchases implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_meatChickenLayersPurchases'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_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 = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatOtherPurchases.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatOtherPurchases.php new file mode 100644 index 00000000..e9de2a3f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerMeatOtherPurchases.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestBroilersInnerMeatOtherPurchases implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_meatOtherPurchases'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_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 = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerSalesInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerSalesInner.php new file mode 100644 index 00000000..6092a301 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestBroilersInnerSalesInner.php @@ -0,0 +1,488 @@ + + */ +class PostPoultryRequestBroilersInnerSalesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_broilers_inner_sales_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'meat_chicken_growers_sales' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner', + 'meat_chicken_layers' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner', + 'meat_other' => '\OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'meat_chicken_growers_sales' => null, + 'meat_chicken_layers' => null, + 'meat_other' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'meat_chicken_growers_sales' => false, + 'meat_chicken_layers' => false, + 'meat_other' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'meat_chicken_growers_sales' => 'meatChickenGrowersSales', + 'meat_chicken_layers' => 'meatChickenLayers', + 'meat_other' => 'meatOther' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'meat_chicken_growers_sales' => 'setMeatChickenGrowersSales', + 'meat_chicken_layers' => 'setMeatChickenLayers', + 'meat_other' => 'setMeatOther' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'meat_chicken_growers_sales' => 'getMeatChickenGrowersSales', + 'meat_chicken_layers' => 'getMeatChickenLayers', + 'meat_other' => 'getMeatOther' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('meat_chicken_growers_sales', $data ?? [], null); + $this->setIfExists('meat_chicken_layers', $data ?? [], null); + $this->setIfExists('meat_other', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['meat_chicken_growers_sales'] === null) { + $invalidProperties[] = "'meat_chicken_growers_sales' can't be null"; + } + if ($this->container['meat_chicken_layers'] === null) { + $invalidProperties[] = "'meat_chicken_layers' can't be null"; + } + if ($this->container['meat_other'] === null) { + $invalidProperties[] = "'meat_other' 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 meat_chicken_growers_sales + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner + */ + public function getMeatChickenGrowersSales() + { + return $this->container['meat_chicken_growers_sales']; + } + + /** + * Sets meat_chicken_growers_sales + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner $meat_chicken_growers_sales meat_chicken_growers_sales + * + * @return self + */ + public function setMeatChickenGrowersSales($meat_chicken_growers_sales) + { + if (is_null($meat_chicken_growers_sales)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_growers_sales cannot be null'); + } + $this->container['meat_chicken_growers_sales'] = $meat_chicken_growers_sales; + + return $this; + } + + /** + * Gets meat_chicken_layers + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner + */ + public function getMeatChickenLayers() + { + return $this->container['meat_chicken_layers']; + } + + /** + * Sets meat_chicken_layers + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner $meat_chicken_layers meat_chicken_layers + * + * @return self + */ + public function setMeatChickenLayers($meat_chicken_layers) + { + if (is_null($meat_chicken_layers)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers cannot be null'); + } + $this->container['meat_chicken_layers'] = $meat_chicken_layers; + + return $this; + } + + /** + * Gets meat_other + * + * @return \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner + */ + public function getMeatOther() + { + return $this->container['meat_other']; + } + + /** + * Sets meat_other + * + * @param \OpenAPI\Client\Model\PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner $meat_other meat_other + * + * @return self + */ + public function setMeatOther($meat_other) + { + if (is_null($meat_other)) { + throw new \InvalidArgumentException('non-nullable meat_other cannot be null'); + } + $this->container['meat_other'] = $meat_other; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInner.php new file mode 100644 index 00000000..ec70dfe8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInner.php @@ -0,0 +1,1311 @@ + + */ +class PostPoultryRequestLayersInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'layers' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayers', + 'meat_chicken_layers' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayers', + 'feed' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[]', + 'purchased_free_range' => 'float', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'hay' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'manure_waste_allocation' => 'float', + 'waste_handled_drylot_or_storage' => 'float', + 'litter_recycled' => 'float', + 'litter_recycle_frequency' => 'float', + 'meat_chicken_layers_purchases' => '\OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases', + 'layers_purchases' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersPurchases', + 'custom_feed_purchased' => 'float', + 'custom_feed_emission_intensity' => 'float', + 'meat_chicken_layers_egg_sale' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayersEggSale', + 'layers_egg_sale' => '\OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersEggSale' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'layers' => null, + 'meat_chicken_layers' => null, + 'feed' => null, + 'purchased_free_range' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'hay' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'manure_waste_allocation' => null, + 'waste_handled_drylot_or_storage' => null, + 'litter_recycled' => null, + 'litter_recycle_frequency' => null, + 'meat_chicken_layers_purchases' => null, + 'layers_purchases' => null, + 'custom_feed_purchased' => null, + 'custom_feed_emission_intensity' => null, + 'meat_chicken_layers_egg_sale' => null, + 'layers_egg_sale' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'layers' => false, + 'meat_chicken_layers' => false, + 'feed' => false, + 'purchased_free_range' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'hay' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'manure_waste_allocation' => false, + 'waste_handled_drylot_or_storage' => false, + 'litter_recycled' => false, + 'litter_recycle_frequency' => false, + 'meat_chicken_layers_purchases' => false, + 'layers_purchases' => false, + 'custom_feed_purchased' => false, + 'custom_feed_emission_intensity' => false, + 'meat_chicken_layers_egg_sale' => false, + 'layers_egg_sale' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'layers' => 'layers', + 'meat_chicken_layers' => 'meatChickenLayers', + 'feed' => 'feed', + 'purchased_free_range' => 'purchasedFreeRange', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'hay' => 'hay', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'manure_waste_allocation' => 'manureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'wasteHandledDrylotOrStorage', + 'litter_recycled' => 'litterRecycled', + 'litter_recycle_frequency' => 'litterRecycleFrequency', + 'meat_chicken_layers_purchases' => 'meatChickenLayersPurchases', + 'layers_purchases' => 'layersPurchases', + 'custom_feed_purchased' => 'customFeedPurchased', + 'custom_feed_emission_intensity' => 'customFeedEmissionIntensity', + 'meat_chicken_layers_egg_sale' => 'meatChickenLayersEggSale', + 'layers_egg_sale' => 'layersEggSale' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'layers' => 'setLayers', + 'meat_chicken_layers' => 'setMeatChickenLayers', + 'feed' => 'setFeed', + 'purchased_free_range' => 'setPurchasedFreeRange', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'hay' => 'setHay', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'manure_waste_allocation' => 'setManureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'setWasteHandledDrylotOrStorage', + 'litter_recycled' => 'setLitterRecycled', + 'litter_recycle_frequency' => 'setLitterRecycleFrequency', + 'meat_chicken_layers_purchases' => 'setMeatChickenLayersPurchases', + 'layers_purchases' => 'setLayersPurchases', + 'custom_feed_purchased' => 'setCustomFeedPurchased', + 'custom_feed_emission_intensity' => 'setCustomFeedEmissionIntensity', + 'meat_chicken_layers_egg_sale' => 'setMeatChickenLayersEggSale', + 'layers_egg_sale' => 'setLayersEggSale' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'layers' => 'getLayers', + 'meat_chicken_layers' => 'getMeatChickenLayers', + 'feed' => 'getFeed', + 'purchased_free_range' => 'getPurchasedFreeRange', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'hay' => 'getHay', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'manure_waste_allocation' => 'getManureWasteAllocation', + 'waste_handled_drylot_or_storage' => 'getWasteHandledDrylotOrStorage', + 'litter_recycled' => 'getLitterRecycled', + 'litter_recycle_frequency' => 'getLitterRecycleFrequency', + 'meat_chicken_layers_purchases' => 'getMeatChickenLayersPurchases', + 'layers_purchases' => 'getLayersPurchases', + 'custom_feed_purchased' => 'getCustomFeedPurchased', + 'custom_feed_emission_intensity' => 'getCustomFeedEmissionIntensity', + 'meat_chicken_layers_egg_sale' => 'getMeatChickenLayersEggSale', + 'layers_egg_sale' => 'getLayersEggSale' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('layers', $data ?? [], null); + $this->setIfExists('meat_chicken_layers', $data ?? [], null); + $this->setIfExists('feed', $data ?? [], null); + $this->setIfExists('purchased_free_range', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('hay', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('manure_waste_allocation', $data ?? [], null); + $this->setIfExists('waste_handled_drylot_or_storage', $data ?? [], null); + $this->setIfExists('litter_recycled', $data ?? [], null); + $this->setIfExists('litter_recycle_frequency', $data ?? [], null); + $this->setIfExists('meat_chicken_layers_purchases', $data ?? [], null); + $this->setIfExists('layers_purchases', $data ?? [], null); + $this->setIfExists('custom_feed_purchased', $data ?? [], null); + $this->setIfExists('custom_feed_emission_intensity', $data ?? [], null); + $this->setIfExists('meat_chicken_layers_egg_sale', $data ?? [], null); + $this->setIfExists('layers_egg_sale', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['layers'] === null) { + $invalidProperties[] = "'layers' can't be null"; + } + if ($this->container['meat_chicken_layers'] === null) { + $invalidProperties[] = "'meat_chicken_layers' can't be null"; + } + if ($this->container['feed'] === null) { + $invalidProperties[] = "'feed' can't be null"; + } + if ($this->container['purchased_free_range'] === null) { + $invalidProperties[] = "'purchased_free_range' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['hay'] === null) { + $invalidProperties[] = "'hay' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['manure_waste_allocation'] === null) { + $invalidProperties[] = "'manure_waste_allocation' can't be null"; + } + if ($this->container['waste_handled_drylot_or_storage'] === null) { + $invalidProperties[] = "'waste_handled_drylot_or_storage' can't be null"; + } + if ($this->container['litter_recycled'] === null) { + $invalidProperties[] = "'litter_recycled' can't be null"; + } + if ($this->container['litter_recycle_frequency'] === null) { + $invalidProperties[] = "'litter_recycle_frequency' can't be null"; + } + if ($this->container['meat_chicken_layers_purchases'] === null) { + $invalidProperties[] = "'meat_chicken_layers_purchases' can't be null"; + } + if ($this->container['layers_purchases'] === null) { + $invalidProperties[] = "'layers_purchases' can't be null"; + } + if ($this->container['custom_feed_purchased'] === null) { + $invalidProperties[] = "'custom_feed_purchased' can't be null"; + } + if ($this->container['custom_feed_emission_intensity'] === null) { + $invalidProperties[] = "'custom_feed_emission_intensity' can't be null"; + } + if ($this->container['meat_chicken_layers_egg_sale'] === null) { + $invalidProperties[] = "'meat_chicken_layers_egg_sale' can't be null"; + } + if ($this->container['layers_egg_sale'] === null) { + $invalidProperties[] = "'layers_egg_sale' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 layers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayers + */ + public function getLayers() + { + return $this->container['layers']; + } + + /** + * Sets layers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayers $layers layers + * + * @return self + */ + public function setLayers($layers) + { + if (is_null($layers)) { + throw new \InvalidArgumentException('non-nullable layers cannot be null'); + } + $this->container['layers'] = $layers; + + return $this; + } + + /** + * Gets meat_chicken_layers + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayers + */ + public function getMeatChickenLayers() + { + return $this->container['meat_chicken_layers']; + } + + /** + * Sets meat_chicken_layers + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayers $meat_chicken_layers meat_chicken_layers + * + * @return self + */ + public function setMeatChickenLayers($meat_chicken_layers) + { + if (is_null($meat_chicken_layers)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers cannot be null'); + } + $this->container['meat_chicken_layers'] = $meat_chicken_layers; + + return $this; + } + + /** + * Gets feed + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[] + */ + public function getFeed() + { + return $this->container['feed']; + } + + /** + * Sets feed + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerGroupsInnerFeedInner[] $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 purchased_free_range + * + * @return float + */ + public function getPurchasedFreeRange() + { + return $this->container['purchased_free_range']; + } + + /** + * Sets purchased_free_range + * + * @param float $purchased_free_range Fraction of chickens purchased that are free range. Note: fraction of chickens purchased that are conventional is `1 - purchasedFreeRange` + * + * @return self + */ + public function setPurchasedFreeRange($purchased_free_range) + { + if (is_null($purchased_free_range)) { + throw new \InvalidArgumentException('non-nullable purchased_free_range cannot be null'); + } + $this->container['purchased_free_range'] = $purchased_free_range; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPoultryRequestLayersInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostPoultryRequestLayersInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets hay + * + * @return float + */ + public function getHay() + { + return $this->container['hay']; + } + + /** + * Sets hay + * + * @param float $hay Hay purchased in tonnes + * + * @return self + */ + public function setHay($hay) + { + if (is_null($hay)) { + throw new \InvalidArgumentException('non-nullable hay cannot be null'); + } + $this->container['hay'] = $hay; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets manure_waste_allocation + * + * @return float + */ + public function getManureWasteAllocation() + { + return $this->container['manure_waste_allocation']; + } + + /** + * Sets manure_waste_allocation + * + * @param float $manure_waste_allocation Fraction allocation of manure waste, from 0 to 1. Note: only for pasture range, paddock and free range systems + * + * @return self + */ + public function setManureWasteAllocation($manure_waste_allocation) + { + if (is_null($manure_waste_allocation)) { + throw new \InvalidArgumentException('non-nullable manure_waste_allocation cannot be null'); + } + $this->container['manure_waste_allocation'] = $manure_waste_allocation; + + return $this; + } + + /** + * Gets waste_handled_drylot_or_storage + * + * @return float + */ + public function getWasteHandledDrylotOrStorage() + { + return $this->container['waste_handled_drylot_or_storage']; + } + + /** + * Sets waste_handled_drylot_or_storage + * + * @param float $waste_handled_drylot_or_storage Fraction of waste handled through dryland and solid storage, from 0 to 1 + * + * @return self + */ + public function setWasteHandledDrylotOrStorage($waste_handled_drylot_or_storage) + { + if (is_null($waste_handled_drylot_or_storage)) { + throw new \InvalidArgumentException('non-nullable waste_handled_drylot_or_storage cannot be null'); + } + $this->container['waste_handled_drylot_or_storage'] = $waste_handled_drylot_or_storage; + + return $this; + } + + /** + * Gets litter_recycled + * + * @return float + */ + public function getLitterRecycled() + { + return $this->container['litter_recycled']; + } + + /** + * Sets litter_recycled + * + * @param float $litter_recycled Fraction of litter recycled, from 0 to 1 + * + * @return self + */ + public function setLitterRecycled($litter_recycled) + { + if (is_null($litter_recycled)) { + throw new \InvalidArgumentException('non-nullable litter_recycled cannot be null'); + } + $this->container['litter_recycled'] = $litter_recycled; + + return $this; + } + + /** + * Gets litter_recycle_frequency + * + * @return float + */ + public function getLitterRecycleFrequency() + { + return $this->container['litter_recycle_frequency']; + } + + /** + * Sets litter_recycle_frequency + * + * @param float $litter_recycle_frequency Number of litter cycles per year + * + * @return self + */ + public function setLitterRecycleFrequency($litter_recycle_frequency) + { + if (is_null($litter_recycle_frequency)) { + throw new \InvalidArgumentException('non-nullable litter_recycle_frequency cannot be null'); + } + $this->container['litter_recycle_frequency'] = $litter_recycle_frequency; + + return $this; + } + + /** + * Gets meat_chicken_layers_purchases + * + * @return \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases + */ + public function getMeatChickenLayersPurchases() + { + return $this->container['meat_chicken_layers_purchases']; + } + + /** + * Sets meat_chicken_layers_purchases + * + * @param \OpenAPI\Client\Model\PostPoultryRequestBroilersInnerMeatChickenLayersPurchases $meat_chicken_layers_purchases meat_chicken_layers_purchases + * + * @return self + */ + public function setMeatChickenLayersPurchases($meat_chicken_layers_purchases) + { + if (is_null($meat_chicken_layers_purchases)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers_purchases cannot be null'); + } + $this->container['meat_chicken_layers_purchases'] = $meat_chicken_layers_purchases; + + return $this; + } + + /** + * Gets layers_purchases + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersPurchases + */ + public function getLayersPurchases() + { + return $this->container['layers_purchases']; + } + + /** + * Sets layers_purchases + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersPurchases $layers_purchases layers_purchases + * + * @return self + */ + public function setLayersPurchases($layers_purchases) + { + if (is_null($layers_purchases)) { + throw new \InvalidArgumentException('non-nullable layers_purchases cannot be null'); + } + $this->container['layers_purchases'] = $layers_purchases; + + return $this; + } + + /** + * Gets custom_feed_purchased + * + * @return float + */ + public function getCustomFeedPurchased() + { + return $this->container['custom_feed_purchased']; + } + + /** + * Sets custom_feed_purchased + * + * @param float $custom_feed_purchased Custom feed purchased, in tonnes + * + * @return self + */ + public function setCustomFeedPurchased($custom_feed_purchased) + { + if (is_null($custom_feed_purchased)) { + throw new \InvalidArgumentException('non-nullable custom_feed_purchased cannot be null'); + } + $this->container['custom_feed_purchased'] = $custom_feed_purchased; + + return $this; + } + + /** + * Gets custom_feed_emission_intensity + * + * @return float + */ + public function getCustomFeedEmissionIntensity() + { + return $this->container['custom_feed_emission_intensity']; + } + + /** + * Sets custom_feed_emission_intensity + * + * @param float $custom_feed_emission_intensity Emissions intensity of custom feed in GHG (kg CO2-e/kg input) + * + * @return self + */ + public function setCustomFeedEmissionIntensity($custom_feed_emission_intensity) + { + if (is_null($custom_feed_emission_intensity)) { + throw new \InvalidArgumentException('non-nullable custom_feed_emission_intensity cannot be null'); + } + $this->container['custom_feed_emission_intensity'] = $custom_feed_emission_intensity; + + return $this; + } + + /** + * Gets meat_chicken_layers_egg_sale + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayersEggSale + */ + public function getMeatChickenLayersEggSale() + { + return $this->container['meat_chicken_layers_egg_sale']; + } + + /** + * Sets meat_chicken_layers_egg_sale + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInnerMeatChickenLayersEggSale $meat_chicken_layers_egg_sale meat_chicken_layers_egg_sale + * + * @return self + */ + public function setMeatChickenLayersEggSale($meat_chicken_layers_egg_sale) + { + if (is_null($meat_chicken_layers_egg_sale)) { + throw new \InvalidArgumentException('non-nullable meat_chicken_layers_egg_sale cannot be null'); + } + $this->container['meat_chicken_layers_egg_sale'] = $meat_chicken_layers_egg_sale; + + return $this; + } + + /** + * Gets layers_egg_sale + * + * @return \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersEggSale + */ + public function getLayersEggSale() + { + return $this->container['layers_egg_sale']; + } + + /** + * Sets layers_egg_sale + * + * @param \OpenAPI\Client\Model\PostPoultryRequestLayersInnerLayersEggSale $layers_egg_sale layers_egg_sale + * + * @return self + */ + public function setLayersEggSale($layers_egg_sale) + { + if (is_null($layers_egg_sale)) { + throw new \InvalidArgumentException('non-nullable layers_egg_sale cannot be null'); + } + $this->container['layers_egg_sale'] = $layers_egg_sale; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayers.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayers.php new file mode 100644 index 00000000..c14922ea --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayers.php @@ -0,0 +1,525 @@ + + */ +class PostPoultryRequestLayersInnerLayers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner_layers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Flock numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Flock numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Flock numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Flock numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersEggSale.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersEggSale.php new file mode 100644 index 00000000..dd4e63da --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersEggSale.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestLayersInnerLayersEggSale implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner_layersEggSale'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'eggs_produced' => 'float', + 'average_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'eggs_produced' => null, + 'average_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'eggs_produced' => false, + 'average_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 = [ + 'eggs_produced' => 'eggsProduced', + 'average_weight' => 'averageWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'eggs_produced' => 'setEggsProduced', + 'average_weight' => 'setAverageWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'eggs_produced' => 'getEggsProduced', + 'average_weight' => 'getAverageWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('eggs_produced', $data ?? [], null); + $this->setIfExists('average_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['eggs_produced'] === null) { + $invalidProperties[] = "'eggs_produced' can't be null"; + } + if ($this->container['average_weight'] === null) { + $invalidProperties[] = "'average_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 eggs_produced + * + * @return float + */ + public function getEggsProduced() + { + return $this->container['eggs_produced']; + } + + /** + * Sets eggs_produced + * + * @param float $eggs_produced Number of eggs produced in a year per bird + * + * @return self + */ + public function setEggsProduced($eggs_produced) + { + if (is_null($eggs_produced)) { + throw new \InvalidArgumentException('non-nullable eggs_produced cannot be null'); + } + $this->container['eggs_produced'] = $eggs_produced; + + return $this; + } + + /** + * Gets average_weight + * + * @return float + */ + public function getAverageWeight() + { + return $this->container['average_weight']; + } + + /** + * Sets average_weight + * + * @param float $average_weight Average egg weight in grams + * + * @return self + */ + public function setAverageWeight($average_weight) + { + if (is_null($average_weight)) { + throw new \InvalidArgumentException('non-nullable average_weight cannot be null'); + } + $this->container['average_weight'] = $average_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersPurchases.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersPurchases.php new file mode 100644 index 00000000..4cb710b8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerLayersPurchases.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestLayersInnerLayersPurchases implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner_layersPurchases'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'purchase_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'purchase_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'purchase_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 = [ + 'head' => 'head', + 'purchase_weight' => 'purchaseWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'purchase_weight' => 'setPurchaseWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'purchase_weight' => 'getPurchaseWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('purchase_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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['purchase_weight'] === null) { + $invalidProperties[] = "'purchase_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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals purchased (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets purchase_weight + * + * @return float + */ + public function getPurchaseWeight() + { + return $this->container['purchase_weight']; + } + + /** + * Sets purchase_weight + * + * @param float $purchase_weight Weight at purchase, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setPurchaseWeight($purchase_weight) + { + if (is_null($purchase_weight)) { + throw new \InvalidArgumentException('non-nullable purchase_weight cannot be null'); + } + $this->container['purchase_weight'] = $purchase_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayers.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayers.php new file mode 100644 index 00000000..2eb2a81e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayers.php @@ -0,0 +1,525 @@ + + */ +class PostPoultryRequestLayersInnerMeatChickenLayers implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner_meatChickenLayers'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn Flock numbers in autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter Flock numbers in winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring Flock numbers in spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer Flock numbers in summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.php new file mode 100644 index 00000000..33586f78 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.php @@ -0,0 +1,451 @@ + + */ +class PostPoultryRequestLayersInnerMeatChickenLayersEggSale implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_layers_inner_meatChickenLayersEggSale'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'eggs_produced' => 'float', + 'average_weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'eggs_produced' => null, + 'average_weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'eggs_produced' => false, + 'average_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 = [ + 'eggs_produced' => 'eggsProduced', + 'average_weight' => 'averageWeight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'eggs_produced' => 'setEggsProduced', + 'average_weight' => 'setAverageWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'eggs_produced' => 'getEggsProduced', + 'average_weight' => 'getAverageWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('eggs_produced', $data ?? [], null); + $this->setIfExists('average_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['eggs_produced'] === null) { + $invalidProperties[] = "'eggs_produced' can't be null"; + } + if ($this->container['average_weight'] === null) { + $invalidProperties[] = "'average_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 eggs_produced + * + * @return float + */ + public function getEggsProduced() + { + return $this->container['eggs_produced']; + } + + /** + * Sets eggs_produced + * + * @param float $eggs_produced Number of eggs produced in a year per bird + * + * @return self + */ + public function setEggsProduced($eggs_produced) + { + if (is_null($eggs_produced)) { + throw new \InvalidArgumentException('non-nullable eggs_produced cannot be null'); + } + $this->container['eggs_produced'] = $eggs_produced; + + return $this; + } + + /** + * Gets average_weight + * + * @return float + */ + public function getAverageWeight() + { + return $this->container['average_weight']; + } + + /** + * Sets average_weight + * + * @param float $average_weight Average egg weight in grams + * + * @return self + */ + public function setAverageWeight($average_weight) + { + if (is_null($average_weight)) { + throw new \InvalidArgumentException('non-nullable average_weight cannot be null'); + } + $this->container['average_weight'] = $average_weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostPoultryRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestVegetationInner.php new file mode 100644 index 00000000..24e50013 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostPoultryRequestVegetationInner.php @@ -0,0 +1,488 @@ + + */ +class PostPoultryRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_poultry_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'broilers_proportion' => 'float[]', + 'layers_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'broilers_proportion' => null, + 'layers_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'broilers_proportion' => false, + 'layers_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'broilers_proportion' => 'broilersProportion', + 'layers_proportion' => 'layersProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'broilers_proportion' => 'setBroilersProportion', + 'layers_proportion' => 'setLayersProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'broilers_proportion' => 'getBroilersProportion', + 'layers_proportion' => 'getLayersProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('broilers_proportion', $data ?? [], null); + $this->setIfExists('layers_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['broilers_proportion'] === null) { + $invalidProperties[] = "'broilers_proportion' can't be null"; + } + if ($this->container['layers_proportion'] === null) { + $invalidProperties[] = "'layers_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets broilers_proportion + * + * @return float[] + */ + public function getBroilersProportion() + { + return $this->container['broilers_proportion']; + } + + /** + * Sets broilers_proportion + * + * @param float[] $broilers_proportion The proportion of the sequestration that is allocated to broilers + * + * @return self + */ + public function setBroilersProportion($broilers_proportion) + { + if (is_null($broilers_proportion)) { + throw new \InvalidArgumentException('non-nullable broilers_proportion cannot be null'); + } + $this->container['broilers_proportion'] = $broilers_proportion; + + return $this; + } + + /** + * Gets layers_proportion + * + * @return float[] + */ + public function getLayersProportion() + { + return $this->container['layers_proportion']; + } + + /** + * Sets layers_proportion + * + * @param float[] $layers_proportion The proportion of the sequestration that is allocated to layers + * + * @return self + */ + public function setLayersProportion($layers_proportion) + { + if (is_null($layers_proportion)) { + throw new \InvalidArgumentException('non-nullable layers_proportion cannot be null'); + } + $this->container['layers_proportion'] = $layers_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200Response.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200Response.php new file mode 100644 index 00000000..1075d18c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200Response.php @@ -0,0 +1,673 @@ + + */ +class PostProcessing200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostProcessing200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostProcessing200ResponseScope3', + 'purchased_offsets' => '\OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets', + 'net' => '\OpenAPI\Client\Model\PostProcessing200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner[]', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostProcessing200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'purchased_offsets' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'purchased_offsets' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'purchased_offsets' => 'purchasedOffsets', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'purchased_offsets' => 'setPurchasedOffsets', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'purchased_offsets' => 'getPurchasedOffsets', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('purchased_offsets', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['purchased_offsets'] === null) { + $invalidProperties[] = "'purchased_offsets' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets purchased_offsets + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets + */ + public function getPurchasedOffsets() + { + return $this->container['purchased_offsets']; + } + + /** + * Sets purchased_offsets + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets $purchased_offsets purchased_offsets + * + * @return self + */ + public function setPurchasedOffsets($purchased_offsets) + { + if (is_null($purchased_offsets)) { + throw new \InvalidArgumentException('non-nullable purchased_offsets cannot be null'); + } + $this->container['purchased_offsets'] = $purchased_offsets; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner[] $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntensitiesInner.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntensitiesInner.php new file mode 100644 index 00000000..ecb45542 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntensitiesInner.php @@ -0,0 +1,564 @@ + + */ +class PostProcessing200ResponseIntensitiesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response_intensities_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'units_produced' => 'float', + 'unit_of_product' => 'string', + 'processing_excluding_carbon_offsets' => 'float', + 'processing_including_carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'units_produced' => null, + 'unit_of_product' => null, + 'processing_excluding_carbon_offsets' => null, + 'processing_including_carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'units_produced' => false, + 'unit_of_product' => false, + 'processing_excluding_carbon_offsets' => false, + 'processing_including_carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'units_produced' => 'unitsProduced', + 'unit_of_product' => 'unitOfProduct', + 'processing_excluding_carbon_offsets' => 'processingExcludingCarbonOffsets', + 'processing_including_carbon_offsets' => 'processingIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'units_produced' => 'setUnitsProduced', + 'unit_of_product' => 'setUnitOfProduct', + 'processing_excluding_carbon_offsets' => 'setProcessingExcludingCarbonOffsets', + 'processing_including_carbon_offsets' => 'setProcessingIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'units_produced' => 'getUnitsProduced', + 'unit_of_product' => 'getUnitOfProduct', + 'processing_excluding_carbon_offsets' => 'getProcessingExcludingCarbonOffsets', + 'processing_including_carbon_offsets' => 'getProcessingIncludingCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const UNIT_OF_PRODUCT_LITRE = 'litre'; + public const UNIT_OF_PRODUCT_TONNE = 'tonne'; + public const UNIT_OF_PRODUCT_UNIT = 'unit'; + public const UNIT_OF_PRODUCT_BOTTLE = 'bottle'; + public const UNIT_OF_PRODUCT_DOZEN = 'dozen'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getUnitOfProductAllowableValues() + { + return [ + self::UNIT_OF_PRODUCT_LITRE, + self::UNIT_OF_PRODUCT_TONNE, + self::UNIT_OF_PRODUCT_UNIT, + self::UNIT_OF_PRODUCT_BOTTLE, + self::UNIT_OF_PRODUCT_DOZEN, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('units_produced', $data ?? [], null); + $this->setIfExists('unit_of_product', $data ?? [], null); + $this->setIfExists('processing_excluding_carbon_offsets', $data ?? [], null); + $this->setIfExists('processing_including_carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['units_produced'] === null) { + $invalidProperties[] = "'units_produced' can't be null"; + } + if ($this->container['unit_of_product'] === null) { + $invalidProperties[] = "'unit_of_product' can't be null"; + } + $allowedValues = $this->getUnitOfProductAllowableValues(); + if (!is_null($this->container['unit_of_product']) && !in_array($this->container['unit_of_product'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'unit_of_product', must be one of '%s'", + $this->container['unit_of_product'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['processing_excluding_carbon_offsets'] === null) { + $invalidProperties[] = "'processing_excluding_carbon_offsets' can't be null"; + } + if ($this->container['processing_including_carbon_offsets'] === null) { + $invalidProperties[] = "'processing_including_carbon_offsets' 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 units_produced + * + * @return float + */ + public function getUnitsProduced() + { + return $this->container['units_produced']; + } + + /** + * Sets units_produced + * + * @param float $units_produced Number of processed product units produced + * + * @return self + */ + public function setUnitsProduced($units_produced) + { + if (is_null($units_produced)) { + throw new \InvalidArgumentException('non-nullable units_produced cannot be null'); + } + $this->container['units_produced'] = $units_produced; + + return $this; + } + + /** + * Gets unit_of_product + * + * @return string + */ + public function getUnitOfProduct() + { + return $this->container['unit_of_product']; + } + + /** + * Sets unit_of_product + * + * @param string $unit_of_product Unit type of the product being produced (used by \"unitsProduced\") + * + * @return self + */ + public function setUnitOfProduct($unit_of_product) + { + if (is_null($unit_of_product)) { + throw new \InvalidArgumentException('non-nullable unit_of_product cannot be null'); + } + $allowedValues = $this->getUnitOfProductAllowableValues(); + if (!in_array($unit_of_product, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'unit_of_product', must be one of '%s'", + $unit_of_product, + implode("', '", $allowedValues) + ) + ); + } + $this->container['unit_of_product'] = $unit_of_product; + + return $this; + } + + /** + * Gets processing_excluding_carbon_offsets + * + * @return float + */ + public function getProcessingExcludingCarbonOffsets() + { + return $this->container['processing_excluding_carbon_offsets']; + } + + /** + * Sets processing_excluding_carbon_offsets + * + * @param float $processing_excluding_carbon_offsets Processing emissions intensity excluding carbon offsets, in kg-CO2e/number of units produced + * + * @return self + */ + public function setProcessingExcludingCarbonOffsets($processing_excluding_carbon_offsets) + { + if (is_null($processing_excluding_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable processing_excluding_carbon_offsets cannot be null'); + } + $this->container['processing_excluding_carbon_offsets'] = $processing_excluding_carbon_offsets; + + return $this; + } + + /** + * Gets processing_including_carbon_offsets + * + * @return float + */ + public function getProcessingIncludingCarbonOffsets() + { + return $this->container['processing_including_carbon_offsets']; + } + + /** + * Sets processing_including_carbon_offsets + * + * @param float $processing_including_carbon_offsets Processing emissions intensity including carbon offsets, in kg-CO2e/number of units produced + * + * @return self + */ + public function setProcessingIncludingCarbonOffsets($processing_including_carbon_offsets) + { + if (is_null($processing_including_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable processing_including_carbon_offsets cannot be null'); + } + $this->container['processing_including_carbon_offsets'] = $processing_including_carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntermediateInner.php new file mode 100644 index 00000000..989c68c7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseIntermediateInner.php @@ -0,0 +1,635 @@ + + */ +class PostProcessing200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostProcessing200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostProcessing200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration', + 'intensities' => '\OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostProcessing200ResponseIntensitiesInner $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseNet.php new file mode 100644 index 00000000..dbacadbc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseNet.php @@ -0,0 +1,414 @@ + + */ +class PostProcessing200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + '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 = [ + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $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['total'] === null) { + $invalidProperties[] = "'total' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope1.php new file mode 100644 index 00000000..d4c0f3c7 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope1.php @@ -0,0 +1,821 @@ + + */ +class PostProcessing200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'hfcs_refrigerant_leakage' => 'float', + 'purchased_co2' => 'float', + 'wastewater_co2' => 'float', + 'composted_solid_waste_co2' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total_hfcs' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'hfcs_refrigerant_leakage' => null, + 'purchased_co2' => null, + 'wastewater_co2' => null, + 'composted_solid_waste_co2' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total_hfcs' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'hfcs_refrigerant_leakage' => false, + 'purchased_co2' => false, + 'wastewater_co2' => false, + 'composted_solid_waste_co2' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => false, + 'total_hfcs' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'hfcs_refrigerant_leakage' => 'hfcsRefrigerantLeakage', + 'purchased_co2' => 'purchasedCO2', + 'wastewater_co2' => 'wastewaterCO2', + 'composted_solid_waste_co2' => 'compostedSolidWasteCO2', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total_hfcs' => 'totalHFCs', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'hfcs_refrigerant_leakage' => 'setHfcsRefrigerantLeakage', + 'purchased_co2' => 'setPurchasedCo2', + 'wastewater_co2' => 'setWastewaterCo2', + 'composted_solid_waste_co2' => 'setCompostedSolidWasteCo2', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total_hfcs' => 'setTotalHfcs', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'hfcs_refrigerant_leakage' => 'getHfcsRefrigerantLeakage', + 'purchased_co2' => 'getPurchasedCo2', + 'wastewater_co2' => 'getWastewaterCo2', + 'composted_solid_waste_co2' => 'getCompostedSolidWasteCo2', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + 'total_hfcs' => 'getTotalHfcs', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('hfcs_refrigerant_leakage', $data ?? [], null); + $this->setIfExists('purchased_co2', $data ?? [], null); + $this->setIfExists('wastewater_co2', $data ?? [], null); + $this->setIfExists('composted_solid_waste_co2', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $data ?? [], null); + $this->setIfExists('total_hfcs', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['hfcs_refrigerant_leakage'] === null) { + $invalidProperties[] = "'hfcs_refrigerant_leakage' can't be null"; + } + if ($this->container['purchased_co2'] === null) { + $invalidProperties[] = "'purchased_co2' can't be null"; + } + if ($this->container['wastewater_co2'] === null) { + $invalidProperties[] = "'wastewater_co2' can't be null"; + } + if ($this->container['composted_solid_waste_co2'] === null) { + $invalidProperties[] = "'composted_solid_waste_co2' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total_hfcs'] === null) { + $invalidProperties[] = "'total_hfcs' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets hfcs_refrigerant_leakage + * + * @return float + */ + public function getHfcsRefrigerantLeakage() + { + return $this->container['hfcs_refrigerant_leakage']; + } + + /** + * Sets hfcs_refrigerant_leakage + * + * @param float $hfcs_refrigerant_leakage Emissions from refrigerant leakage, in tonnes-HFCs + * + * @return self + */ + public function setHfcsRefrigerantLeakage($hfcs_refrigerant_leakage) + { + if (is_null($hfcs_refrigerant_leakage)) { + throw new \InvalidArgumentException('non-nullable hfcs_refrigerant_leakage cannot be null'); + } + $this->container['hfcs_refrigerant_leakage'] = $hfcs_refrigerant_leakage; + + return $this; + } + + /** + * Gets purchased_co2 + * + * @return float + */ + public function getPurchasedCo2() + { + return $this->container['purchased_co2']; + } + + /** + * Sets purchased_co2 + * + * @param float $purchased_co2 Emissions from purchased CO2, in tonnes-CO2e + * + * @return self + */ + public function setPurchasedCo2($purchased_co2) + { + if (is_null($purchased_co2)) { + throw new \InvalidArgumentException('non-nullable purchased_co2 cannot be null'); + } + $this->container['purchased_co2'] = $purchased_co2; + + return $this; + } + + /** + * Gets wastewater_co2 + * + * @return float + */ + public function getWastewaterCo2() + { + return $this->container['wastewater_co2']; + } + + /** + * Sets wastewater_co2 + * + * @param float $wastewater_co2 Emissions from wastewater, in tonnes-CO2e + * + * @return self + */ + public function setWastewaterCo2($wastewater_co2) + { + if (is_null($wastewater_co2)) { + throw new \InvalidArgumentException('non-nullable wastewater_co2 cannot be null'); + } + $this->container['wastewater_co2'] = $wastewater_co2; + + return $this; + } + + /** + * Gets composted_solid_waste_co2 + * + * @return float + */ + public function getCompostedSolidWasteCo2() + { + return $this->container['composted_solid_waste_co2']; + } + + /** + * Sets composted_solid_waste_co2 + * + * @param float $composted_solid_waste_co2 Emissions from composted solid waste, in tonnes-CO2e + * + * @return self + */ + public function setCompostedSolidWasteCo2($composted_solid_waste_co2) + { + if (is_null($composted_solid_waste_co2)) { + throw new \InvalidArgumentException('non-nullable composted_solid_waste_co2 cannot be null'); + } + $this->container['composted_solid_waste_co2'] = $composted_solid_waste_co2; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total_hfcs + * + * @return float + */ + public function getTotalHfcs() + { + return $this->container['total_hfcs']; + } + + /** + * Sets total_hfcs + * + * @param float $total_hfcs Total HFCs scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalHfcs($total_hfcs) + { + if (is_null($total_hfcs)) { + throw new \InvalidArgumentException('non-nullable total_hfcs cannot be null'); + } + $this->container['total_hfcs'] = $total_hfcs; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope3.php new file mode 100644 index 00000000..a0e682fc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessing200ResponseScope3.php @@ -0,0 +1,525 @@ + + */ +class PostProcessing200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'electricity' => 'float', + 'fuel' => 'float', + 'solid_waste_sent_offsite' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'electricity' => null, + 'fuel' => null, + 'solid_waste_sent_offsite' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'electricity' => false, + 'fuel' => false, + 'solid_waste_sent_offsite' => 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 = [ + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'solid_waste_sent_offsite' => 'solidWasteSentOffsite', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'solid_waste_sent_offsite' => 'setSolidWasteSentOffsite', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'solid_waste_sent_offsite' => 'getSolidWasteSentOffsite', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('solid_waste_sent_offsite', $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['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['solid_waste_sent_offsite'] === null) { + $invalidProperties[] = "'solid_waste_sent_offsite' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets solid_waste_sent_offsite + * + * @return float + */ + public function getSolidWasteSentOffsite() + { + return $this->container['solid_waste_sent_offsite']; + } + + /** + * Sets solid_waste_sent_offsite + * + * @param float $solid_waste_sent_offsite Emissions from solid waste sent offsite, in tonnes-CO2e + * + * @return self + */ + public function setSolidWasteSentOffsite($solid_waste_sent_offsite) + { + if (is_null($solid_waste_sent_offsite)) { + throw new \InvalidArgumentException('non-nullable solid_waste_sent_offsite cannot be null'); + } + $this->container['solid_waste_sent_offsite'] = $solid_waste_sent_offsite; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessingRequest.php b/examples/php-api-client/api-client/lib/Model/PostProcessingRequest.php new file mode 100644 index 00000000..9a431dd8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessingRequest.php @@ -0,0 +1,499 @@ + + */ +class PostProcessingRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'products' => '\OpenAPI\Client\Model\PostProcessingRequestProductsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'products' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'products' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'products' => 'products' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'products' => 'setProducts' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'products' => 'getProducts' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('products', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['products'] === null) { + $invalidProperties[] = "'products' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets products + * + * @return \OpenAPI\Client\Model\PostProcessingRequestProductsInner[] + */ + public function getProducts() + { + return $this->container['products']; + } + + /** + * Sets products + * + * @param \OpenAPI\Client\Model\PostProcessingRequestProductsInner[] $products products + * + * @return self + */ + public function setProducts($products) + { + if (is_null($products)) { + throw new \InvalidArgumentException('non-nullable products cannot be null'); + } + $this->container['products'] = $products; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInner.php b/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInner.php new file mode 100644 index 00000000..63ae69bf --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInner.php @@ -0,0 +1,828 @@ + + */ +class PostProcessingRequestProductsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_request_products_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'product' => '\OpenAPI\Client\Model\PostProcessingRequestProductsInnerProduct', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'electricity_source' => 'string', + 'fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel', + 'refrigerants' => '\OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[]', + 'fluid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[]', + 'solid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste', + 'purchased_co2' => 'float', + 'carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'product' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'electricity_source' => null, + 'fuel' => null, + 'refrigerants' => null, + 'fluid_waste' => null, + 'solid_waste' => null, + 'purchased_co2' => null, + 'carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'product' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'electricity_source' => false, + 'fuel' => false, + 'refrigerants' => false, + 'fluid_waste' => false, + 'solid_waste' => false, + 'purchased_co2' => false, + 'carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'product' => 'product', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'electricity_source' => 'electricitySource', + 'fuel' => 'fuel', + 'refrigerants' => 'refrigerants', + 'fluid_waste' => 'fluidWaste', + 'solid_waste' => 'solidWaste', + 'purchased_co2' => 'purchasedCO2', + 'carbon_offsets' => 'carbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'product' => 'setProduct', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'electricity_source' => 'setElectricitySource', + 'fuel' => 'setFuel', + 'refrigerants' => 'setRefrigerants', + 'fluid_waste' => 'setFluidWaste', + 'solid_waste' => 'setSolidWaste', + 'purchased_co2' => 'setPurchasedCo2', + 'carbon_offsets' => 'setCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'product' => 'getProduct', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'electricity_source' => 'getElectricitySource', + 'fuel' => 'getFuel', + 'refrigerants' => 'getRefrigerants', + 'fluid_waste' => 'getFluidWaste', + 'solid_waste' => 'getSolidWaste', + 'purchased_co2' => 'getPurchasedCo2', + 'carbon_offsets' => 'getCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('product', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('refrigerants', $data ?? [], null); + $this->setIfExists('fluid_waste', $data ?? [], null); + $this->setIfExists('solid_waste', $data ?? [], null); + $this->setIfExists('purchased_co2', $data ?? [], null); + $this->setIfExists('carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['product'] === null) { + $invalidProperties[] = "'product' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['refrigerants'] === null) { + $invalidProperties[] = "'refrigerants' can't be null"; + } + if ($this->container['fluid_waste'] === null) { + $invalidProperties[] = "'fluid_waste' can't be null"; + } + if ($this->container['solid_waste'] === null) { + $invalidProperties[] = "'solid_waste' can't be null"; + } + if ($this->container['purchased_co2'] === null) { + $invalidProperties[] = "'purchased_co2' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 product + * + * @return \OpenAPI\Client\Model\PostProcessingRequestProductsInnerProduct + */ + public function getProduct() + { + return $this->container['product']; + } + + /** + * Sets product + * + * @param \OpenAPI\Client\Model\PostProcessingRequestProductsInnerProduct $product product + * + * @return self + */ + public function setProduct($product) + { + if (is_null($product)) { + throw new \InvalidArgumentException('non-nullable product cannot be null'); + } + $this->container['product'] = $product; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostProcessingRequestProductsInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostProcessingRequestProductsInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel $fuel fuel + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets refrigerants + * + * @return \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] + */ + public function getRefrigerants() + { + return $this->container['refrigerants']; + } + + /** + * Sets refrigerants + * + * @param \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] $refrigerants Refrigerant type + * + * @return self + */ + public function setRefrigerants($refrigerants) + { + if (is_null($refrigerants)) { + throw new \InvalidArgumentException('non-nullable refrigerants cannot be null'); + } + $this->container['refrigerants'] = $refrigerants; + + return $this; + } + + /** + * Gets fluid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] + */ + public function getFluidWaste() + { + return $this->container['fluid_waste']; + } + + /** + * Sets fluid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] $fluid_waste Amount of fluid waste, in kL (kilolitres) + * + * @return self + */ + public function setFluidWaste($fluid_waste) + { + if (is_null($fluid_waste)) { + throw new \InvalidArgumentException('non-nullable fluid_waste cannot be null'); + } + $this->container['fluid_waste'] = $fluid_waste; + + return $this; + } + + /** + * Gets solid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste + */ + public function getSolidWaste() + { + return $this->container['solid_waste']; + } + + /** + * Sets solid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste $solid_waste solid_waste + * + * @return self + */ + public function setSolidWaste($solid_waste) + { + if (is_null($solid_waste)) { + throw new \InvalidArgumentException('non-nullable solid_waste cannot be null'); + } + $this->container['solid_waste'] = $solid_waste; + + return $this; + } + + /** + * Gets purchased_co2 + * + * @return float + */ + public function getPurchasedCo2() + { + return $this->container['purchased_co2']; + } + + /** + * Sets purchased_co2 + * + * @param float $purchased_co2 Quantity of CO2 purchased, in kg CO2 + * + * @return self + */ + public function setPurchasedCo2($purchased_co2) + { + if (is_null($purchased_co2)) { + throw new \InvalidArgumentException('non-nullable purchased_co2 cannot be null'); + } + $this->container['purchased_co2'] = $purchased_co2; + + return $this; + } + + /** + * Gets carbon_offsets + * + * @return float|null + */ + public function getCarbonOffsets() + { + return $this->container['carbon_offsets']; + } + + /** + * Sets carbon_offsets + * + * @param float|null $carbon_offsets Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0) + * + * @return self + */ + public function setCarbonOffsets($carbon_offsets) + { + if (is_null($carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable carbon_offsets cannot be null'); + } + $this->container['carbon_offsets'] = $carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInnerProduct.php b/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInnerProduct.php new file mode 100644 index 00000000..8ba8129a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostProcessingRequestProductsInnerProduct.php @@ -0,0 +1,491 @@ + + */ +class PostProcessingRequestProductsInnerProduct implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_processing_request_products_inner_product'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'unit' => 'string', + 'amount_made_per_year' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'unit' => null, + 'amount_made_per_year' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'unit' => false, + 'amount_made_per_year' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'unit' => 'unit', + 'amount_made_per_year' => 'amountMadePerYear' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'unit' => 'setUnit', + 'amount_made_per_year' => 'setAmountMadePerYear' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'unit' => 'getUnit', + 'amount_made_per_year' => 'getAmountMadePerYear' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const UNIT_LITRE = 'litre'; + public const UNIT_TONNE = 'tonne'; + public const UNIT_UNIT = 'unit'; + public const UNIT_BOTTLE = 'bottle'; + public const UNIT_DOZEN = 'dozen'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getUnitAllowableValues() + { + return [ + self::UNIT_LITRE, + self::UNIT_TONNE, + self::UNIT_UNIT, + self::UNIT_BOTTLE, + self::UNIT_DOZEN, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('unit', $data ?? [], null); + $this->setIfExists('amount_made_per_year', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['unit'] === null) { + $invalidProperties[] = "'unit' can't be null"; + } + $allowedValues = $this->getUnitAllowableValues(); + if (!is_null($this->container['unit']) && !in_array($this->container['unit'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'unit', must be one of '%s'", + $this->container['unit'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['amount_made_per_year'] === null) { + $invalidProperties[] = "'amount_made_per_year' 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 unit + * + * @return string + */ + public function getUnit() + { + return $this->container['unit']; + } + + /** + * Sets unit + * + * @param string $unit unit + * + * @return self + */ + public function setUnit($unit) + { + if (is_null($unit)) { + throw new \InvalidArgumentException('non-nullable unit cannot be null'); + } + $allowedValues = $this->getUnitAllowableValues(); + if (!in_array($unit, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'unit', must be one of '%s'", + $unit, + implode("', '", $allowedValues) + ) + ); + } + $this->container['unit'] = $unit; + + return $this; + } + + /** + * Gets amount_made_per_year + * + * @return float + */ + public function getAmountMadePerYear() + { + return $this->container['amount_made_per_year']; + } + + /** + * Sets amount_made_per_year + * + * @param float $amount_made_per_year amount_made_per_year + * + * @return self + */ + public function setAmountMadePerYear($amount_made_per_year) + { + if (is_null($amount_made_per_year)) { + throw new \InvalidArgumentException('non-nullable amount_made_per_year cannot be null'); + } + $this->container['amount_made_per_year'] = $amount_made_per_year; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRice200Response.php b/examples/php-api-client/api-client/lib/Model/PostRice200Response.php new file mode 100644 index 00000000..fa6edc66 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRice200Response.php @@ -0,0 +1,636 @@ + + */ +class PostRice200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostRice200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostRice200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostCotton200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostRice200ResponseIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostRice200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostRice200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostRice200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostRice200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostRice200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostRice200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntensities.php new file mode 100644 index 00000000..8f219689 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntensities.php @@ -0,0 +1,527 @@ + + */ +class PostRice200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rice_produced_tonnes' => 'float', + 'rice_excluding_sequestration' => 'float', + 'rice_including_sequestration' => 'float', + 'intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rice_produced_tonnes' => null, + 'rice_excluding_sequestration' => null, + 'rice_including_sequestration' => null, + 'intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rice_produced_tonnes' => false, + 'rice_excluding_sequestration' => false, + 'rice_including_sequestration' => false, + 'intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rice_produced_tonnes' => 'riceProducedTonnes', + 'rice_excluding_sequestration' => 'riceExcludingSequestration', + 'rice_including_sequestration' => 'riceIncludingSequestration', + 'intensity' => 'intensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rice_produced_tonnes' => 'setRiceProducedTonnes', + 'rice_excluding_sequestration' => 'setRiceExcludingSequestration', + 'rice_including_sequestration' => 'setRiceIncludingSequestration', + 'intensity' => 'setIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rice_produced_tonnes' => 'getRiceProducedTonnes', + 'rice_excluding_sequestration' => 'getRiceExcludingSequestration', + 'rice_including_sequestration' => 'getRiceIncludingSequestration', + 'intensity' => 'getIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('rice_produced_tonnes', $data ?? [], null); + $this->setIfExists('rice_excluding_sequestration', $data ?? [], null); + $this->setIfExists('rice_including_sequestration', $data ?? [], null); + $this->setIfExists('intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['rice_produced_tonnes'] === null) { + $invalidProperties[] = "'rice_produced_tonnes' can't be null"; + } + if ($this->container['rice_excluding_sequestration'] === null) { + $invalidProperties[] = "'rice_excluding_sequestration' can't be null"; + } + if ($this->container['rice_including_sequestration'] === null) { + $invalidProperties[] = "'rice_including_sequestration' can't be null"; + } + if ($this->container['intensity'] === null) { + $invalidProperties[] = "'intensity' 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 rice_produced_tonnes + * + * @return float + */ + public function getRiceProducedTonnes() + { + return $this->container['rice_produced_tonnes']; + } + + /** + * Sets rice_produced_tonnes + * + * @param float $rice_produced_tonnes Rice produced in tonnes + * + * @return self + */ + public function setRiceProducedTonnes($rice_produced_tonnes) + { + if (is_null($rice_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable rice_produced_tonnes cannot be null'); + } + $this->container['rice_produced_tonnes'] = $rice_produced_tonnes; + + return $this; + } + + /** + * Gets rice_excluding_sequestration + * + * @return float + */ + public function getRiceExcludingSequestration() + { + return $this->container['rice_excluding_sequestration']; + } + + /** + * Sets rice_excluding_sequestration + * + * @param float $rice_excluding_sequestration Rice excluding sequestration, in t-CO2e/t rice + * + * @return self + */ + public function setRiceExcludingSequestration($rice_excluding_sequestration) + { + if (is_null($rice_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable rice_excluding_sequestration cannot be null'); + } + $this->container['rice_excluding_sequestration'] = $rice_excluding_sequestration; + + return $this; + } + + /** + * Gets rice_including_sequestration + * + * @return float + */ + public function getRiceIncludingSequestration() + { + return $this->container['rice_including_sequestration']; + } + + /** + * Sets rice_including_sequestration + * + * @param float $rice_including_sequestration Rice including sequestration, in t-CO2e/t rice + * + * @return self + */ + public function setRiceIncludingSequestration($rice_including_sequestration) + { + if (is_null($rice_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable rice_including_sequestration cannot be null'); + } + $this->container['rice_including_sequestration'] = $rice_including_sequestration; + + return $this; + } + + /** + * Gets intensity + * + * @return float + * @deprecated + */ + public function getIntensity() + { + return $this->container['intensity']; + } + + /** + * Sets intensity + * + * @param float $intensity Emissions intensity of rice production. Deprecation note: Use `riceIncludingSequestration` instead + * + * @return self + * @deprecated + */ + public function setIntensity($intensity) + { + if (is_null($intensity)) { + throw new \InvalidArgumentException('non-nullable intensity cannot be null'); + } + $this->container['intensity'] = $intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInner.php new file mode 100644 index 00000000..48965366 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostRice200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostRice200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostRice200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostRice200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostRice200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostRice200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostRice200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..103554bb --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,526 @@ + + */ +class PostRice200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rice_produced_tonnes' => 'float', + 'rice_excluding_sequestration' => 'float', + 'rice_including_sequestration' => 'float', + 'intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rice_produced_tonnes' => null, + 'rice_excluding_sequestration' => null, + 'rice_including_sequestration' => null, + 'intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rice_produced_tonnes' => false, + 'rice_excluding_sequestration' => false, + 'rice_including_sequestration' => false, + 'intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rice_produced_tonnes' => 'riceProducedTonnes', + 'rice_excluding_sequestration' => 'riceExcludingSequestration', + 'rice_including_sequestration' => 'riceIncludingSequestration', + 'intensity' => 'intensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rice_produced_tonnes' => 'setRiceProducedTonnes', + 'rice_excluding_sequestration' => 'setRiceExcludingSequestration', + 'rice_including_sequestration' => 'setRiceIncludingSequestration', + 'intensity' => 'setIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rice_produced_tonnes' => 'getRiceProducedTonnes', + 'rice_excluding_sequestration' => 'getRiceExcludingSequestration', + 'rice_including_sequestration' => 'getRiceIncludingSequestration', + 'intensity' => 'getIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('rice_produced_tonnes', $data ?? [], null); + $this->setIfExists('rice_excluding_sequestration', $data ?? [], null); + $this->setIfExists('rice_including_sequestration', $data ?? [], null); + $this->setIfExists('intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['rice_produced_tonnes'] === null) { + $invalidProperties[] = "'rice_produced_tonnes' can't be null"; + } + if ($this->container['rice_excluding_sequestration'] === null) { + $invalidProperties[] = "'rice_excluding_sequestration' can't be null"; + } + if ($this->container['rice_including_sequestration'] === null) { + $invalidProperties[] = "'rice_including_sequestration' can't be null"; + } + if ($this->container['intensity'] === null) { + $invalidProperties[] = "'intensity' 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 rice_produced_tonnes + * + * @return float + */ + public function getRiceProducedTonnes() + { + return $this->container['rice_produced_tonnes']; + } + + /** + * Sets rice_produced_tonnes + * + * @param float $rice_produced_tonnes Rice produced in tonnes + * + * @return self + */ + public function setRiceProducedTonnes($rice_produced_tonnes) + { + if (is_null($rice_produced_tonnes)) { + throw new \InvalidArgumentException('non-nullable rice_produced_tonnes cannot be null'); + } + $this->container['rice_produced_tonnes'] = $rice_produced_tonnes; + + return $this; + } + + /** + * Gets rice_excluding_sequestration + * + * @return float + */ + public function getRiceExcludingSequestration() + { + return $this->container['rice_excluding_sequestration']; + } + + /** + * Sets rice_excluding_sequestration + * + * @param float $rice_excluding_sequestration Rice excluding sequestration, in t-CO2e/t rice + * + * @return self + */ + public function setRiceExcludingSequestration($rice_excluding_sequestration) + { + if (is_null($rice_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable rice_excluding_sequestration cannot be null'); + } + $this->container['rice_excluding_sequestration'] = $rice_excluding_sequestration; + + return $this; + } + + /** + * Gets rice_including_sequestration + * + * @return float + */ + public function getRiceIncludingSequestration() + { + return $this->container['rice_including_sequestration']; + } + + /** + * Sets rice_including_sequestration + * + * @param float $rice_including_sequestration Rice including sequestration, in t-CO2e/t rice + * + * @return self + */ + public function setRiceIncludingSequestration($rice_including_sequestration) + { + if (is_null($rice_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable rice_including_sequestration cannot be null'); + } + $this->container['rice_including_sequestration'] = $rice_including_sequestration; + + return $this; + } + + /** + * Gets intensity + * + * @return float + * @deprecated + */ + public function getIntensity() + { + return $this->container['intensity']; + } + + /** + * Sets intensity + * + * @param float $intensity Emissions intensity of rice production. Deprecation note: Use `riceIncludingSequestration` instead + * + * @return self + * @deprecated + */ + public function setIntensity($intensity) + { + if (is_null($intensity)) { + throw new \InvalidArgumentException('non-nullable intensity cannot be null'); + } + $this->container['intensity'] = $intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRice200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseScope1.php new file mode 100644 index 00000000..a3fd4550 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRice200ResponseScope1.php @@ -0,0 +1,969 @@ + + */ +class PostRice200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'lime_co2' => 'float', + 'urea_co2' => 'float', + 'field_burning_ch4' => 'float', + 'rice_cultivation_ch4' => 'float', + 'fuel_ch4' => 'float', + 'fertiliser_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'field_burning_n2_o' => 'float', + 'crop_residue_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'fuel_n2_o' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'lime_co2' => null, + 'urea_co2' => null, + 'field_burning_ch4' => null, + 'rice_cultivation_ch4' => null, + 'fuel_ch4' => null, + 'fertiliser_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'field_burning_n2_o' => null, + 'crop_residue_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'fuel_n2_o' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'lime_co2' => false, + 'urea_co2' => false, + 'field_burning_ch4' => false, + 'rice_cultivation_ch4' => false, + 'fuel_ch4' => false, + 'fertiliser_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'field_burning_n2_o' => false, + 'crop_residue_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'fuel_n2_o' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'lime_co2' => 'limeCO2', + 'urea_co2' => 'ureaCO2', + 'field_burning_ch4' => 'fieldBurningCH4', + 'rice_cultivation_ch4' => 'riceCultivationCH4', + 'fuel_ch4' => 'fuelCH4', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'field_burning_n2_o' => 'fieldBurningN2O', + 'crop_residue_n2_o' => 'cropResidueN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'fuel_n2_o' => 'fuelN2O', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'lime_co2' => 'setLimeCo2', + 'urea_co2' => 'setUreaCo2', + 'field_burning_ch4' => 'setFieldBurningCh4', + 'rice_cultivation_ch4' => 'setRiceCultivationCh4', + 'fuel_ch4' => 'setFuelCh4', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'field_burning_n2_o' => 'setFieldBurningN2O', + 'crop_residue_n2_o' => 'setCropResidueN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'fuel_n2_o' => 'setFuelN2O', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'lime_co2' => 'getLimeCo2', + 'urea_co2' => 'getUreaCo2', + 'field_burning_ch4' => 'getFieldBurningCh4', + 'rice_cultivation_ch4' => 'getRiceCultivationCh4', + 'fuel_ch4' => 'getFuelCh4', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'field_burning_n2_o' => 'getFieldBurningN2O', + 'crop_residue_n2_o' => 'getCropResidueN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'fuel_n2_o' => 'getFuelN2O', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('field_burning_ch4', $data ?? [], null); + $this->setIfExists('rice_cultivation_ch4', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('field_burning_n2_o', $data ?? [], null); + $this->setIfExists('crop_residue_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['field_burning_ch4'] === null) { + $invalidProperties[] = "'field_burning_ch4' can't be null"; + } + if ($this->container['rice_cultivation_ch4'] === null) { + $invalidProperties[] = "'rice_cultivation_ch4' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['field_burning_n2_o'] === null) { + $invalidProperties[] = "'field_burning_n2_o' can't be null"; + } + if ($this->container['crop_residue_n2_o'] === null) { + $invalidProperties[] = "'crop_residue_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets field_burning_ch4 + * + * @return float + */ + public function getFieldBurningCh4() + { + return $this->container['field_burning_ch4']; + } + + /** + * Sets field_burning_ch4 + * + * @param float $field_burning_ch4 CH4 emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningCh4($field_burning_ch4) + { + if (is_null($field_burning_ch4)) { + throw new \InvalidArgumentException('non-nullable field_burning_ch4 cannot be null'); + } + $this->container['field_burning_ch4'] = $field_burning_ch4; + + return $this; + } + + /** + * Gets rice_cultivation_ch4 + * + * @return float + */ + public function getRiceCultivationCh4() + { + return $this->container['rice_cultivation_ch4']; + } + + /** + * Sets rice_cultivation_ch4 + * + * @param float $rice_cultivation_ch4 CH4 emissions from rice cultivation, in tonnes-CO2e + * + * @return self + */ + public function setRiceCultivationCh4($rice_cultivation_ch4) + { + if (is_null($rice_cultivation_ch4)) { + throw new \InvalidArgumentException('non-nullable rice_cultivation_ch4 cannot be null'); + } + $this->container['rice_cultivation_ch4'] = $rice_cultivation_ch4; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets field_burning_n2_o + * + * @return float + */ + public function getFieldBurningN2O() + { + return $this->container['field_burning_n2_o']; + } + + /** + * Sets field_burning_n2_o + * + * @param float $field_burning_n2_o N2O emissions from field burning, in tonnes-CO2e + * + * @return self + */ + public function setFieldBurningN2O($field_burning_n2_o) + { + if (is_null($field_burning_n2_o)) { + throw new \InvalidArgumentException('non-nullable field_burning_n2_o cannot be null'); + } + $this->container['field_burning_n2_o'] = $field_burning_n2_o; + + return $this; + } + + /** + * Gets crop_residue_n2_o + * + * @return float + */ + public function getCropResidueN2O() + { + return $this->container['crop_residue_n2_o']; + } + + /** + * Sets crop_residue_n2_o + * + * @param float $crop_residue_n2_o N2O emissions from crop residue, in tonnes-CO2e + * + * @return self + */ + public function setCropResidueN2O($crop_residue_n2_o) + { + if (is_null($crop_residue_n2_o)) { + throw new \InvalidArgumentException('non-nullable crop_residue_n2_o cannot be null'); + } + $this->container['crop_residue_n2_o'] = $crop_residue_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRiceRequest.php b/examples/php-api-client/api-client/lib/Model/PostRiceRequest.php new file mode 100644 index 00000000..f454a467 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRiceRequest.php @@ -0,0 +1,626 @@ + + */ +class PostRiceRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'crops' => '\OpenAPI\Client\Model\PostRiceRequestCropsInner[]', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'vegetation' => '\OpenAPI\Client\Model\PostCottonRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'crops' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'crops' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'crops' => 'crops', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'crops' => 'setCrops', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'crops' => 'getCrops', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets crops + * + * @return \OpenAPI\Client\Model\PostRiceRequestCropsInner[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param \OpenAPI\Client\Model\PostRiceRequestCropsInner[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostRiceRequest., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostRiceRequest., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostRiceRequestCropsInner.php b/examples/php-api-client/api-client/lib/Model/PostRiceRequestCropsInner.php new file mode 100644 index 00000000..118f3711 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostRiceRequestCropsInner.php @@ -0,0 +1,1424 @@ + + */ +class PostRiceRequestCropsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_rice_request_crops_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'average_rice_yield' => 'float', + 'area_sown' => 'float', + 'growing_season_days' => 'float', + 'water_regime_type' => 'string', + 'water_regime_sub_type' => 'string', + 'rice_preseason_flooding_period' => 'string', + 'urea_application' => 'float', + 'non_urea_nitrogen' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'fraction_of_annual_crop_burnt' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_allocation' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'diesel_use' => 'float', + 'petrol_use' => 'float', + 'lpg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'average_rice_yield' => null, + 'area_sown' => null, + 'growing_season_days' => null, + 'water_regime_type' => null, + 'water_regime_sub_type' => null, + 'rice_preseason_flooding_period' => null, + 'urea_application' => null, + 'non_urea_nitrogen' => null, + 'urea_ammonium_nitrate' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'fraction_of_annual_crop_burnt' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_allocation' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'diesel_use' => null, + 'petrol_use' => null, + 'lpg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'average_rice_yield' => false, + 'area_sown' => false, + 'growing_season_days' => false, + 'water_regime_type' => false, + 'water_regime_sub_type' => false, + 'rice_preseason_flooding_period' => false, + 'urea_application' => false, + 'non_urea_nitrogen' => false, + 'urea_ammonium_nitrate' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'fraction_of_annual_crop_burnt' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_allocation' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'diesel_use' => false, + 'petrol_use' => false, + 'lpg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'average_rice_yield' => 'averageRiceYield', + 'area_sown' => 'areaSown', + 'growing_season_days' => 'growingSeasonDays', + 'water_regime_type' => 'waterRegimeType', + 'water_regime_sub_type' => 'waterRegimeSubType', + 'rice_preseason_flooding_period' => 'ricePreseasonFloodingPeriod', + 'urea_application' => 'ureaApplication', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'fraction_of_annual_crop_burnt' => 'fractionOfAnnualCropBurnt', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_allocation' => 'electricityAllocation', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'diesel_use' => 'dieselUse', + 'petrol_use' => 'petrolUse', + 'lpg' => 'lpg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'average_rice_yield' => 'setAverageRiceYield', + 'area_sown' => 'setAreaSown', + 'growing_season_days' => 'setGrowingSeasonDays', + 'water_regime_type' => 'setWaterRegimeType', + 'water_regime_sub_type' => 'setWaterRegimeSubType', + 'rice_preseason_flooding_period' => 'setRicePreseasonFloodingPeriod', + 'urea_application' => 'setUreaApplication', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'fraction_of_annual_crop_burnt' => 'setFractionOfAnnualCropBurnt', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'setElectricityAllocation', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'diesel_use' => 'setDieselUse', + 'petrol_use' => 'setPetrolUse', + 'lpg' => 'setLpg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'average_rice_yield' => 'getAverageRiceYield', + 'area_sown' => 'getAreaSown', + 'growing_season_days' => 'getGrowingSeasonDays', + 'water_regime_type' => 'getWaterRegimeType', + 'water_regime_sub_type' => 'getWaterRegimeSubType', + 'rice_preseason_flooding_period' => 'getRicePreseasonFloodingPeriod', + 'urea_application' => 'getUreaApplication', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'fraction_of_annual_crop_burnt' => 'getFractionOfAnnualCropBurnt', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'getElectricityAllocation', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'diesel_use' => 'getDieselUse', + 'petrol_use' => 'getPetrolUse', + 'lpg' => 'getLpg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const WATER_REGIME_TYPE_UPLAND = 'Upland'; + public const WATER_REGIME_TYPE_IRRIGATED = 'Irrigated'; + public const WATER_REGIME_TYPE_RAINFED = 'Rainfed'; + public const WATER_REGIME_SUB_TYPE_CONTINUOUSLY_FLOODED = 'Continuously flooded'; + public const WATER_REGIME_SUB_TYPE_SINGLE_DRAINAGE_PERIOD = 'Single drainage period'; + public const WATER_REGIME_SUB_TYPE_MULTIPLE_DRAINAGE_PERIODS = 'Multiple drainage periods'; + public const WATER_REGIME_SUB_TYPE_REGULAR_RAINFED = 'Regular rainfed'; + public const WATER_REGIME_SUB_TYPE_DROUGHT_PRONE = 'Drought prone'; + public const WATER_REGIME_SUB_TYPE_DEEP_WATER = 'Deep water'; + public const WATER_REGIME_SUB_TYPE_PADDY_ROTATION = 'Paddy rotation'; + public const WATER_REGIME_SUB_TYPE_FALLOW_WITHOUT_FLOODING_IN_PREVIOUS_YEAR = 'Fallow without flooding in previous year'; + public const RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__180_DAYS = 'Non flooded pre-season < 180 days'; + public const RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__180_DAYS2 = 'Non flooded pre-season > 180 days'; + public const RICE_PRESEASON_FLOODING_PERIOD_FLOODED_PRE_SEASON__30_DAYS = 'Flooded pre-season > 30 days'; + public const RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__365_DAYS = 'Non-flooded pre-season > 365 days'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getWaterRegimeTypeAllowableValues() + { + return [ + self::WATER_REGIME_TYPE_UPLAND, + self::WATER_REGIME_TYPE_IRRIGATED, + self::WATER_REGIME_TYPE_RAINFED, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getWaterRegimeSubTypeAllowableValues() + { + return [ + self::WATER_REGIME_SUB_TYPE_CONTINUOUSLY_FLOODED, + self::WATER_REGIME_SUB_TYPE_SINGLE_DRAINAGE_PERIOD, + self::WATER_REGIME_SUB_TYPE_MULTIPLE_DRAINAGE_PERIODS, + self::WATER_REGIME_SUB_TYPE_REGULAR_RAINFED, + self::WATER_REGIME_SUB_TYPE_DROUGHT_PRONE, + self::WATER_REGIME_SUB_TYPE_DEEP_WATER, + self::WATER_REGIME_SUB_TYPE_PADDY_ROTATION, + self::WATER_REGIME_SUB_TYPE_FALLOW_WITHOUT_FLOODING_IN_PREVIOUS_YEAR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRicePreseasonFloodingPeriodAllowableValues() + { + return [ + self::RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__180_DAYS, + self::RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__180_DAYS2, + self::RICE_PRESEASON_FLOODING_PERIOD_FLOODED_PRE_SEASON__30_DAYS, + self::RICE_PRESEASON_FLOODING_PERIOD_NON_FLOODED_PRE_SEASON__365_DAYS, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('average_rice_yield', $data ?? [], null); + $this->setIfExists('area_sown', $data ?? [], null); + $this->setIfExists('growing_season_days', $data ?? [], null); + $this->setIfExists('water_regime_type', $data ?? [], null); + $this->setIfExists('water_regime_sub_type', $data ?? [], null); + $this->setIfExists('rice_preseason_flooding_period', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], null); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], null); + $this->setIfExists('phosphorus_application', $data ?? [], null); + $this->setIfExists('potassium_application', $data ?? [], null); + $this->setIfExists('sulfur_application', $data ?? [], null); + $this->setIfExists('fraction_of_annual_crop_burnt', $data ?? [], null); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_allocation', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('diesel_use', $data ?? [], null); + $this->setIfExists('petrol_use', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_rice_yield'] === null) { + $invalidProperties[] = "'average_rice_yield' can't be null"; + } + if ($this->container['area_sown'] === null) { + $invalidProperties[] = "'area_sown' can't be null"; + } + if ($this->container['growing_season_days'] === null) { + $invalidProperties[] = "'growing_season_days' can't be null"; + } + if ($this->container['water_regime_type'] === null) { + $invalidProperties[] = "'water_regime_type' can't be null"; + } + $allowedValues = $this->getWaterRegimeTypeAllowableValues(); + if (!is_null($this->container['water_regime_type']) && !in_array($this->container['water_regime_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'water_regime_type', must be one of '%s'", + $this->container['water_regime_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['water_regime_sub_type'] === null) { + $invalidProperties[] = "'water_regime_sub_type' can't be null"; + } + $allowedValues = $this->getWaterRegimeSubTypeAllowableValues(); + if (!is_null($this->container['water_regime_sub_type']) && !in_array($this->container['water_regime_sub_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'water_regime_sub_type', must be one of '%s'", + $this->container['water_regime_sub_type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rice_preseason_flooding_period'] === null) { + $invalidProperties[] = "'rice_preseason_flooding_period' can't be null"; + } + $allowedValues = $this->getRicePreseasonFloodingPeriodAllowableValues(); + if (!is_null($this->container['rice_preseason_flooding_period']) && !in_array($this->container['rice_preseason_flooding_period'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'rice_preseason_flooding_period', must be one of '%s'", + $this->container['rice_preseason_flooding_period'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['fraction_of_annual_crop_burnt'] === null) { + $invalidProperties[] = "'fraction_of_annual_crop_burnt' can't be null"; + } + if (($this->container['fraction_of_annual_crop_burnt'] > 1)) { + $invalidProperties[] = "invalid value for 'fraction_of_annual_crop_burnt', must be smaller than or equal to 1."; + } + + if (($this->container['fraction_of_annual_crop_burnt'] < 0)) { + $invalidProperties[] = "invalid value for 'fraction_of_annual_crop_burnt', must be bigger than or equal to 0."; + } + + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_allocation'] === null) { + $invalidProperties[] = "'electricity_allocation' can't be null"; + } + if (($this->container['electricity_allocation'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_allocation', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_allocation'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_allocation', must be bigger than or equal to 0."; + } + + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['diesel_use'] === null) { + $invalidProperties[] = "'diesel_use' can't be null"; + } + if ($this->container['petrol_use'] === null) { + $invalidProperties[] = "'petrol_use' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets average_rice_yield + * + * @return float + */ + public function getAverageRiceYield() + { + return $this->container['average_rice_yield']; + } + + /** + * Sets average_rice_yield + * + * @param float $average_rice_yield Average rice yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageRiceYield($average_rice_yield) + { + if (is_null($average_rice_yield)) { + throw new \InvalidArgumentException('non-nullable average_rice_yield cannot be null'); + } + $this->container['average_rice_yield'] = $average_rice_yield; + + return $this; + } + + /** + * Gets area_sown + * + * @return float + */ + public function getAreaSown() + { + return $this->container['area_sown']; + } + + /** + * Sets area_sown + * + * @param float $area_sown Area sown, in ha (hectares) + * + * @return self + */ + public function setAreaSown($area_sown) + { + if (is_null($area_sown)) { + throw new \InvalidArgumentException('non-nullable area_sown cannot be null'); + } + $this->container['area_sown'] = $area_sown; + + return $this; + } + + /** + * Gets growing_season_days + * + * @return float + */ + public function getGrowingSeasonDays() + { + return $this->container['growing_season_days']; + } + + /** + * Sets growing_season_days + * + * @param float $growing_season_days The length of the growing season for this crop, in days + * + * @return self + */ + public function setGrowingSeasonDays($growing_season_days) + { + if (is_null($growing_season_days)) { + throw new \InvalidArgumentException('non-nullable growing_season_days cannot be null'); + } + $this->container['growing_season_days'] = $growing_season_days; + + return $this; + } + + /** + * Gets water_regime_type + * + * @return string + */ + public function getWaterRegimeType() + { + return $this->container['water_regime_type']; + } + + /** + * Sets water_regime_type + * + * @param string $water_regime_type water_regime_type + * + * @return self + */ + public function setWaterRegimeType($water_regime_type) + { + if (is_null($water_regime_type)) { + throw new \InvalidArgumentException('non-nullable water_regime_type cannot be null'); + } + $allowedValues = $this->getWaterRegimeTypeAllowableValues(); + if (!in_array($water_regime_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'water_regime_type', must be one of '%s'", + $water_regime_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['water_regime_type'] = $water_regime_type; + + return $this; + } + + /** + * Gets water_regime_sub_type + * + * @return string + */ + public function getWaterRegimeSubType() + { + return $this->container['water_regime_sub_type']; + } + + /** + * Sets water_regime_sub_type + * + * @param string $water_regime_sub_type water_regime_sub_type + * + * @return self + */ + public function setWaterRegimeSubType($water_regime_sub_type) + { + if (is_null($water_regime_sub_type)) { + throw new \InvalidArgumentException('non-nullable water_regime_sub_type cannot be null'); + } + $allowedValues = $this->getWaterRegimeSubTypeAllowableValues(); + if (!in_array($water_regime_sub_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'water_regime_sub_type', must be one of '%s'", + $water_regime_sub_type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['water_regime_sub_type'] = $water_regime_sub_type; + + return $this; + } + + /** + * Gets rice_preseason_flooding_period + * + * @return string + */ + public function getRicePreseasonFloodingPeriod() + { + return $this->container['rice_preseason_flooding_period']; + } + + /** + * Sets rice_preseason_flooding_period + * + * @param string $rice_preseason_flooding_period rice_preseason_flooding_period + * + * @return self + */ + public function setRicePreseasonFloodingPeriod($rice_preseason_flooding_period) + { + if (is_null($rice_preseason_flooding_period)) { + throw new \InvalidArgumentException('non-nullable rice_preseason_flooding_period cannot be null'); + } + $allowedValues = $this->getRicePreseasonFloodingPeriodAllowableValues(); + if (!in_array($rice_preseason_flooding_period, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'rice_preseason_flooding_period', must be one of '%s'", + $rice_preseason_flooding_period, + implode("', '", $allowedValues) + ) + ); + } + $this->container['rice_preseason_flooding_period'] = $rice_preseason_flooding_period; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets fraction_of_annual_crop_burnt + * + * @return float + */ + public function getFractionOfAnnualCropBurnt() + { + return $this->container['fraction_of_annual_crop_burnt']; + } + + /** + * Sets fraction_of_annual_crop_burnt + * + * @param float $fraction_of_annual_crop_burnt Fraction of annual production of crop that is burnt, from 0 to 1 + * + * @return self + */ + public function setFractionOfAnnualCropBurnt($fraction_of_annual_crop_burnt) + { + if (is_null($fraction_of_annual_crop_burnt)) { + throw new \InvalidArgumentException('non-nullable fraction_of_annual_crop_burnt cannot be null'); + } + + if (($fraction_of_annual_crop_burnt > 1)) { + throw new \InvalidArgumentException('invalid value for $fraction_of_annual_crop_burnt when calling PostRiceRequestCropsInner., must be smaller than or equal to 1.'); + } + if (($fraction_of_annual_crop_burnt < 0)) { + throw new \InvalidArgumentException('invalid value for $fraction_of_annual_crop_burnt when calling PostRiceRequestCropsInner., must be bigger than or equal to 0.'); + } + + $this->container['fraction_of_annual_crop_burnt'] = $fraction_of_annual_crop_burnt; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_allocation + * + * @return float + */ + public function getElectricityAllocation() + { + return $this->container['electricity_allocation']; + } + + /** + * Sets electricity_allocation + * + * @param float $electricity_allocation Percentage of electricity use to allocate to this crop, from 0 to 1 + * + * @return self + */ + public function setElectricityAllocation($electricity_allocation) + { + if (is_null($electricity_allocation)) { + throw new \InvalidArgumentException('non-nullable electricity_allocation cannot be null'); + } + + if (($electricity_allocation > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_allocation when calling PostRiceRequestCropsInner., must be smaller than or equal to 1.'); + } + if (($electricity_allocation < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_allocation when calling PostRiceRequestCropsInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_allocation'] = $electricity_allocation; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets diesel_use + * + * @return float + */ + public function getDieselUse() + { + return $this->container['diesel_use']; + } + + /** + * Sets diesel_use + * + * @param float $diesel_use Diesel usage in L (litres) + * + * @return self + */ + public function setDieselUse($diesel_use) + { + if (is_null($diesel_use)) { + throw new \InvalidArgumentException('non-nullable diesel_use cannot be null'); + } + $this->container['diesel_use'] = $diesel_use; + + return $this; + } + + /** + * Gets petrol_use + * + * @return float + */ + public function getPetrolUse() + { + return $this->container['petrol_use']; + } + + /** + * Sets petrol_use + * + * @param float $petrol_use Petrol usage in L (litres) + * + * @return self + */ + public function setPetrolUse($petrol_use) + { + if (is_null($petrol_use)) { + throw new \InvalidArgumentException('non-nullable petrol_use cannot be null'); + } + $this->container['petrol_use'] = $petrol_use; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheep200Response.php b/examples/php-api-client/api-client/lib/Model/PostSheep200Response.php new file mode 100644 index 00000000..703dc248 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheep200Response.php @@ -0,0 +1,636 @@ + + */ +class PostSheep200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostSheep200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInner.php new file mode 100644 index 00000000..f03d1bd5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInner.php @@ -0,0 +1,635 @@ + + */ +class PostSheep200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostBuffalo200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBuffalo200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..ece3f05f --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,598 @@ + + */ +class PostSheep200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'wool_produced_kg' => 'float', + 'sheep_meat_produced_kg' => 'float', + 'wool_including_sequestration' => 'float', + 'wool_excluding_sequestration' => 'float', + 'sheep_meat_breeding_including_sequestration' => 'float', + 'sheep_meat_breeding_excluding_sequestration' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'wool_produced_kg' => null, + 'sheep_meat_produced_kg' => null, + 'wool_including_sequestration' => null, + 'wool_excluding_sequestration' => null, + 'sheep_meat_breeding_including_sequestration' => null, + 'sheep_meat_breeding_excluding_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'wool_produced_kg' => false, + 'sheep_meat_produced_kg' => false, + 'wool_including_sequestration' => false, + 'wool_excluding_sequestration' => false, + 'sheep_meat_breeding_including_sequestration' => false, + 'sheep_meat_breeding_excluding_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'wool_produced_kg' => 'woolProducedKg', + 'sheep_meat_produced_kg' => 'sheepMeatProducedKg', + 'wool_including_sequestration' => 'woolIncludingSequestration', + 'wool_excluding_sequestration' => 'woolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'sheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'sheepMeatBreedingExcludingSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'wool_produced_kg' => 'setWoolProducedKg', + 'sheep_meat_produced_kg' => 'setSheepMeatProducedKg', + 'wool_including_sequestration' => 'setWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'setWoolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'setSheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'setSheepMeatBreedingExcludingSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'wool_produced_kg' => 'getWoolProducedKg', + 'sheep_meat_produced_kg' => 'getSheepMeatProducedKg', + 'wool_including_sequestration' => 'getWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'getWoolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'getSheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'getSheepMeatBreedingExcludingSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('wool_produced_kg', $data ?? [], null); + $this->setIfExists('sheep_meat_produced_kg', $data ?? [], null); + $this->setIfExists('wool_including_sequestration', $data ?? [], null); + $this->setIfExists('wool_excluding_sequestration', $data ?? [], null); + $this->setIfExists('sheep_meat_breeding_including_sequestration', $data ?? [], null); + $this->setIfExists('sheep_meat_breeding_excluding_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['wool_produced_kg'] === null) { + $invalidProperties[] = "'wool_produced_kg' can't be null"; + } + if ($this->container['sheep_meat_produced_kg'] === null) { + $invalidProperties[] = "'sheep_meat_produced_kg' can't be null"; + } + if ($this->container['wool_including_sequestration'] === null) { + $invalidProperties[] = "'wool_including_sequestration' can't be null"; + } + if ($this->container['wool_excluding_sequestration'] === null) { + $invalidProperties[] = "'wool_excluding_sequestration' can't be null"; + } + if ($this->container['sheep_meat_breeding_including_sequestration'] === null) { + $invalidProperties[] = "'sheep_meat_breeding_including_sequestration' can't be null"; + } + if ($this->container['sheep_meat_breeding_excluding_sequestration'] === null) { + $invalidProperties[] = "'sheep_meat_breeding_excluding_sequestration' 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 wool_produced_kg + * + * @return float + */ + public function getWoolProducedKg() + { + return $this->container['wool_produced_kg']; + } + + /** + * Sets wool_produced_kg + * + * @param float $wool_produced_kg Greasy wool produced in kg + * + * @return self + */ + public function setWoolProducedKg($wool_produced_kg) + { + if (is_null($wool_produced_kg)) { + throw new \InvalidArgumentException('non-nullable wool_produced_kg cannot be null'); + } + $this->container['wool_produced_kg'] = $wool_produced_kg; + + return $this; + } + + /** + * Gets sheep_meat_produced_kg + * + * @return float + */ + public function getSheepMeatProducedKg() + { + return $this->container['sheep_meat_produced_kg']; + } + + /** + * Sets sheep_meat_produced_kg + * + * @param float $sheep_meat_produced_kg Sheep meat produced in kg liveweight + * + * @return self + */ + public function setSheepMeatProducedKg($sheep_meat_produced_kg) + { + if (is_null($sheep_meat_produced_kg)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_produced_kg cannot be null'); + } + $this->container['sheep_meat_produced_kg'] = $sheep_meat_produced_kg; + + return $this; + } + + /** + * Gets wool_including_sequestration + * + * @return float + */ + public function getWoolIncludingSequestration() + { + return $this->container['wool_including_sequestration']; + } + + /** + * Sets wool_including_sequestration + * + * @param float $wool_including_sequestration Wool production including carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolIncludingSequestration($wool_including_sequestration) + { + if (is_null($wool_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_including_sequestration cannot be null'); + } + $this->container['wool_including_sequestration'] = $wool_including_sequestration; + + return $this; + } + + /** + * Gets wool_excluding_sequestration + * + * @return float + */ + public function getWoolExcludingSequestration() + { + return $this->container['wool_excluding_sequestration']; + } + + /** + * Sets wool_excluding_sequestration + * + * @param float $wool_excluding_sequestration Wool production excluding carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolExcludingSequestration($wool_excluding_sequestration) + { + if (is_null($wool_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_excluding_sequestration cannot be null'); + } + $this->container['wool_excluding_sequestration'] = $wool_excluding_sequestration; + + return $this; + } + + /** + * Gets sheep_meat_breeding_including_sequestration + * + * @return float + */ + public function getSheepMeatBreedingIncludingSequestration() + { + return $this->container['sheep_meat_breeding_including_sequestration']; + } + + /** + * Sets sheep_meat_breeding_including_sequestration + * + * @param float $sheep_meat_breeding_including_sequestration Sheep meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setSheepMeatBreedingIncludingSequestration($sheep_meat_breeding_including_sequestration) + { + if (is_null($sheep_meat_breeding_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_breeding_including_sequestration cannot be null'); + } + $this->container['sheep_meat_breeding_including_sequestration'] = $sheep_meat_breeding_including_sequestration; + + return $this; + } + + /** + * Gets sheep_meat_breeding_excluding_sequestration + * + * @return float + */ + public function getSheepMeatBreedingExcludingSequestration() + { + return $this->container['sheep_meat_breeding_excluding_sequestration']; + } + + /** + * Sets sheep_meat_breeding_excluding_sequestration + * + * @param float $sheep_meat_breeding_excluding_sequestration Sheep meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setSheepMeatBreedingExcludingSequestration($sheep_meat_breeding_excluding_sequestration) + { + if (is_null($sheep_meat_breeding_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_breeding_excluding_sequestration cannot be null'); + } + $this->container['sheep_meat_breeding_excluding_sequestration'] = $sheep_meat_breeding_excluding_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseNet.php new file mode 100644 index 00000000..c79b7cc1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheep200ResponseNet.php @@ -0,0 +1,450 @@ + + */ +class PostSheep200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'sheep' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'sheep' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'sheep' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'sheep' => 'sheep' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'sheep' => 'setSheep' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'sheep' => 'getSheep' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('sheep', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['sheep'] === null) { + $invalidProperties[] = "'sheep' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total net emissions of this activity, in tonnes-CO2e/year + * + * @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 sheep + * + * @return float + */ + public function getSheep() + { + return $this->container['sheep']; + } + + /** + * Sets sheep + * + * @param float $sheep Net emissions of sheep, in tonnes-CO2e/year + * + * @return self + */ + public function setSheep($sheep) + { + if (is_null($sheep)) { + throw new \InvalidArgumentException('non-nullable sheep cannot be null'); + } + $this->container['sheep'] = $sheep; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequest.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequest.php new file mode 100644 index 00000000..13cd6dda --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequest.php @@ -0,0 +1,610 @@ + + */ +class PostSheepRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'north_of_tropic_of_capricorn' => 'bool', + 'rainfall_above600' => 'bool', + 'sheep' => '\OpenAPI\Client\Model\PostSheepRequestSheepInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostSheepRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'north_of_tropic_of_capricorn' => null, + 'rainfall_above600' => null, + 'sheep' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'north_of_tropic_of_capricorn' => false, + 'rainfall_above600' => false, + 'sheep' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'north_of_tropic_of_capricorn' => 'northOfTropicOfCapricorn', + 'rainfall_above600' => 'rainfallAbove600', + 'sheep' => 'sheep', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'north_of_tropic_of_capricorn' => 'setNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'setRainfallAbove600', + 'sheep' => 'setSheep', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'north_of_tropic_of_capricorn' => 'getNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'getRainfallAbove600', + 'sheep' => 'getSheep', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('north_of_tropic_of_capricorn', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('sheep', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['north_of_tropic_of_capricorn'] === null) { + $invalidProperties[] = "'north_of_tropic_of_capricorn' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['sheep'] === null) { + $invalidProperties[] = "'sheep' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets north_of_tropic_of_capricorn + * + * @return bool + */ + public function getNorthOfTropicOfCapricorn() + { + return $this->container['north_of_tropic_of_capricorn']; + } + + /** + * Sets north_of_tropic_of_capricorn + * + * @param bool $north_of_tropic_of_capricorn Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude + * + * @return self + */ + public function setNorthOfTropicOfCapricorn($north_of_tropic_of_capricorn) + { + if (is_null($north_of_tropic_of_capricorn)) { + throw new \InvalidArgumentException('non-nullable north_of_tropic_of_capricorn cannot be null'); + } + $this->container['north_of_tropic_of_capricorn'] = $north_of_tropic_of_capricorn; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets sheep + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInner[] + */ + public function getSheep() + { + return $this->container['sheep']; + } + + /** + * Sets sheep + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInner[] $sheep sheep + * + * @return self + */ + public function setSheep($sheep) + { + if (is_null($sheep)) { + throw new \InvalidArgumentException('non-nullable sheep cannot be null'); + } + $this->container['sheep'] = $sheep; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostSheepRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostSheepRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInner.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInner.php new file mode 100644 index 00000000..cd1bf211 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInner.php @@ -0,0 +1,1126 @@ + + */ +class PostSheepRequestSheepInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'classes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClasses', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'fertiliser' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'mineral_supplementation' => '\OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'grain_feed' => 'float', + 'hay_feed' => 'float', + 'herbicide' => 'float', + 'herbicide_other' => 'float', + 'merino_percent' => 'float', + 'ewes_lambing' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerEwesLambing', + 'seasonal_lambing' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerSeasonalLambing' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'classes' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'fertiliser' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'mineral_supplementation' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'grain_feed' => null, + 'hay_feed' => null, + 'herbicide' => null, + 'herbicide_other' => null, + 'merino_percent' => null, + 'ewes_lambing' => null, + 'seasonal_lambing' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'classes' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'fertiliser' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'mineral_supplementation' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'grain_feed' => false, + 'hay_feed' => false, + 'herbicide' => false, + 'herbicide_other' => false, + 'merino_percent' => false, + 'ewes_lambing' => false, + 'seasonal_lambing' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'classes' => 'classes', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'fertiliser' => 'fertiliser', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'mineral_supplementation' => 'mineralSupplementation', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'grain_feed' => 'grainFeed', + 'hay_feed' => 'hayFeed', + 'herbicide' => 'herbicide', + 'herbicide_other' => 'herbicideOther', + 'merino_percent' => 'merinoPercent', + 'ewes_lambing' => 'ewesLambing', + 'seasonal_lambing' => 'seasonalLambing' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'classes' => 'setClasses', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'fertiliser' => 'setFertiliser', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'mineral_supplementation' => 'setMineralSupplementation', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'grain_feed' => 'setGrainFeed', + 'hay_feed' => 'setHayFeed', + 'herbicide' => 'setHerbicide', + 'herbicide_other' => 'setHerbicideOther', + 'merino_percent' => 'setMerinoPercent', + 'ewes_lambing' => 'setEwesLambing', + 'seasonal_lambing' => 'setSeasonalLambing' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'classes' => 'getClasses', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'fertiliser' => 'getFertiliser', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'mineral_supplementation' => 'getMineralSupplementation', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'grain_feed' => 'getGrainFeed', + 'hay_feed' => 'getHayFeed', + 'herbicide' => 'getHerbicide', + 'herbicide_other' => 'getHerbicideOther', + 'merino_percent' => 'getMerinoPercent', + 'ewes_lambing' => 'getEwesLambing', + 'seasonal_lambing' => 'getSeasonalLambing' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('classes', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('mineral_supplementation', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('grain_feed', $data ?? [], null); + $this->setIfExists('hay_feed', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('herbicide_other', $data ?? [], null); + $this->setIfExists('merino_percent', $data ?? [], null); + $this->setIfExists('ewes_lambing', $data ?? [], null); + $this->setIfExists('seasonal_lambing', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['classes'] === null) { + $invalidProperties[] = "'classes' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['mineral_supplementation'] === null) { + $invalidProperties[] = "'mineral_supplementation' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['grain_feed'] === null) { + $invalidProperties[] = "'grain_feed' can't be null"; + } + if ($this->container['hay_feed'] === null) { + $invalidProperties[] = "'hay_feed' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['herbicide_other'] === null) { + $invalidProperties[] = "'herbicide_other' can't be null"; + } + if ($this->container['merino_percent'] === null) { + $invalidProperties[] = "'merino_percent' can't be null"; + } + if ($this->container['ewes_lambing'] === null) { + $invalidProperties[] = "'ewes_lambing' can't be null"; + } + if ($this->container['seasonal_lambing'] === null) { + $invalidProperties[] = "'seasonal_lambing' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 classes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClasses + */ + public function getClasses() + { + return $this->container['classes']; + } + + /** + * Sets classes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClasses $classes classes + * + * @return self + */ + public function setClasses($classes) + { + if (is_null($classes)) { + throw new \InvalidArgumentException('non-nullable classes cannot be null'); + } + $this->container['classes'] = $classes; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets fertiliser + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerFertiliser $fertiliser fertiliser + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets mineral_supplementation + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation + */ + public function getMineralSupplementation() + { + return $this->container['mineral_supplementation']; + } + + /** + * Sets mineral_supplementation + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInnerMineralSupplementation $mineral_supplementation mineral_supplementation + * + * @return self + */ + public function setMineralSupplementation($mineral_supplementation) + { + if (is_null($mineral_supplementation)) { + throw new \InvalidArgumentException('non-nullable mineral_supplementation cannot be null'); + } + $this->container['mineral_supplementation'] = $mineral_supplementation; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostSheepRequestSheepInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostSheepRequestSheepInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets grain_feed + * + * @return float + */ + public function getGrainFeed() + { + return $this->container['grain_feed']; + } + + /** + * Sets grain_feed + * + * @param float $grain_feed Grain purchased for cattle feed in tonnes + * + * @return self + */ + public function setGrainFeed($grain_feed) + { + if (is_null($grain_feed)) { + throw new \InvalidArgumentException('non-nullable grain_feed cannot be null'); + } + $this->container['grain_feed'] = $grain_feed; + + return $this; + } + + /** + * Gets hay_feed + * + * @return float + */ + public function getHayFeed() + { + return $this->container['hay_feed']; + } + + /** + * Sets hay_feed + * + * @param float $hay_feed Hay purchased for cattle feed in tonnes + * + * @return self + */ + public function setHayFeed($hay_feed) + { + if (is_null($hay_feed)) { + throw new \InvalidArgumentException('non-nullable hay_feed cannot be null'); + } + $this->container['hay_feed'] = $hay_feed; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms) + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets herbicide_other + * + * @return float + */ + public function getHerbicideOther() + { + return $this->container['herbicide_other']; + } + + /** + * Sets herbicide_other + * + * @param float $herbicide_other Total amount of active ingredients of from other herbicides in kg (kilograms) + * + * @return self + */ + public function setHerbicideOther($herbicide_other) + { + if (is_null($herbicide_other)) { + throw new \InvalidArgumentException('non-nullable herbicide_other cannot be null'); + } + $this->container['herbicide_other'] = $herbicide_other; + + return $this; + } + + /** + * Gets merino_percent + * + * @return float + */ + public function getMerinoPercent() + { + return $this->container['merino_percent']; + } + + /** + * Sets merino_percent + * + * @param float $merino_percent Percent of sheep purchases that are of type Merino, from 0 to 100 + * + * @return self + */ + public function setMerinoPercent($merino_percent) + { + if (is_null($merino_percent)) { + throw new \InvalidArgumentException('non-nullable merino_percent cannot be null'); + } + $this->container['merino_percent'] = $merino_percent; + + return $this; + } + + /** + * Gets ewes_lambing + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerEwesLambing + */ + public function getEwesLambing() + { + return $this->container['ewes_lambing']; + } + + /** + * Sets ewes_lambing + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerEwesLambing $ewes_lambing ewes_lambing + * + * @return self + */ + public function setEwesLambing($ewes_lambing) + { + if (is_null($ewes_lambing)) { + throw new \InvalidArgumentException('non-nullable ewes_lambing cannot be null'); + } + $this->container['ewes_lambing'] = $ewes_lambing; + + return $this; + } + + /** + * Gets seasonal_lambing + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerSeasonalLambing + */ + public function getSeasonalLambing() + { + return $this->container['seasonal_lambing']; + } + + /** + * Sets seasonal_lambing + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerSeasonalLambing $seasonal_lambing seasonal_lambing + * + * @return self + */ + public function setSeasonalLambing($seasonal_lambing) + { + if (is_null($seasonal_lambing)) { + throw new \InvalidArgumentException('non-nullable seasonal_lambing cannot be null'); + } + $this->container['seasonal_lambing'] = $seasonal_lambing; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClasses.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClasses.php new file mode 100644 index 00000000..51165122 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClasses.php @@ -0,0 +1,933 @@ + + */ +class PostSheepRequestSheepInnerClasses implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_classes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rams' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_rams' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'wethers' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_wethers' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'maiden_breeding_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_maiden_breeding_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'breeding_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_breeding_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'other_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_other_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'ewe_lambs' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_ewe_lambs' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'wether_lambs' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_wether_lambs' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams', + 'trade_ewes' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeEwes', + 'trade_lambs_and_hoggets' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeLambsAndHoggets' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rams' => null, + 'trade_rams' => null, + 'wethers' => null, + 'trade_wethers' => null, + 'maiden_breeding_ewes' => null, + 'trade_maiden_breeding_ewes' => null, + 'breeding_ewes' => null, + 'trade_breeding_ewes' => null, + 'other_ewes' => null, + 'trade_other_ewes' => null, + 'ewe_lambs' => null, + 'trade_ewe_lambs' => null, + 'wether_lambs' => null, + 'trade_wether_lambs' => null, + 'trade_ewes' => null, + 'trade_lambs_and_hoggets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rams' => false, + 'trade_rams' => false, + 'wethers' => false, + 'trade_wethers' => false, + 'maiden_breeding_ewes' => false, + 'trade_maiden_breeding_ewes' => false, + 'breeding_ewes' => false, + 'trade_breeding_ewes' => false, + 'other_ewes' => false, + 'trade_other_ewes' => false, + 'ewe_lambs' => false, + 'trade_ewe_lambs' => false, + 'wether_lambs' => false, + 'trade_wether_lambs' => false, + 'trade_ewes' => false, + 'trade_lambs_and_hoggets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rams' => 'rams', + 'trade_rams' => 'tradeRams', + 'wethers' => 'wethers', + 'trade_wethers' => 'tradeWethers', + 'maiden_breeding_ewes' => 'maidenBreedingEwes', + 'trade_maiden_breeding_ewes' => 'tradeMaidenBreedingEwes', + 'breeding_ewes' => 'breedingEwes', + 'trade_breeding_ewes' => 'tradeBreedingEwes', + 'other_ewes' => 'otherEwes', + 'trade_other_ewes' => 'tradeOtherEwes', + 'ewe_lambs' => 'eweLambs', + 'trade_ewe_lambs' => 'tradeEweLambs', + 'wether_lambs' => 'wetherLambs', + 'trade_wether_lambs' => 'tradeWetherLambs', + 'trade_ewes' => 'tradeEwes', + 'trade_lambs_and_hoggets' => 'tradeLambsAndHoggets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rams' => 'setRams', + 'trade_rams' => 'setTradeRams', + 'wethers' => 'setWethers', + 'trade_wethers' => 'setTradeWethers', + 'maiden_breeding_ewes' => 'setMaidenBreedingEwes', + 'trade_maiden_breeding_ewes' => 'setTradeMaidenBreedingEwes', + 'breeding_ewes' => 'setBreedingEwes', + 'trade_breeding_ewes' => 'setTradeBreedingEwes', + 'other_ewes' => 'setOtherEwes', + 'trade_other_ewes' => 'setTradeOtherEwes', + 'ewe_lambs' => 'setEweLambs', + 'trade_ewe_lambs' => 'setTradeEweLambs', + 'wether_lambs' => 'setWetherLambs', + 'trade_wether_lambs' => 'setTradeWetherLambs', + 'trade_ewes' => 'setTradeEwes', + 'trade_lambs_and_hoggets' => 'setTradeLambsAndHoggets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rams' => 'getRams', + 'trade_rams' => 'getTradeRams', + 'wethers' => 'getWethers', + 'trade_wethers' => 'getTradeWethers', + 'maiden_breeding_ewes' => 'getMaidenBreedingEwes', + 'trade_maiden_breeding_ewes' => 'getTradeMaidenBreedingEwes', + 'breeding_ewes' => 'getBreedingEwes', + 'trade_breeding_ewes' => 'getTradeBreedingEwes', + 'other_ewes' => 'getOtherEwes', + 'trade_other_ewes' => 'getTradeOtherEwes', + 'ewe_lambs' => 'getEweLambs', + 'trade_ewe_lambs' => 'getTradeEweLambs', + 'wether_lambs' => 'getWetherLambs', + 'trade_wether_lambs' => 'getTradeWetherLambs', + 'trade_ewes' => 'getTradeEwes', + 'trade_lambs_and_hoggets' => 'getTradeLambsAndHoggets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('rams', $data ?? [], null); + $this->setIfExists('trade_rams', $data ?? [], null); + $this->setIfExists('wethers', $data ?? [], null); + $this->setIfExists('trade_wethers', $data ?? [], null); + $this->setIfExists('maiden_breeding_ewes', $data ?? [], null); + $this->setIfExists('trade_maiden_breeding_ewes', $data ?? [], null); + $this->setIfExists('breeding_ewes', $data ?? [], null); + $this->setIfExists('trade_breeding_ewes', $data ?? [], null); + $this->setIfExists('other_ewes', $data ?? [], null); + $this->setIfExists('trade_other_ewes', $data ?? [], null); + $this->setIfExists('ewe_lambs', $data ?? [], null); + $this->setIfExists('trade_ewe_lambs', $data ?? [], null); + $this->setIfExists('wether_lambs', $data ?? [], null); + $this->setIfExists('trade_wether_lambs', $data ?? [], null); + $this->setIfExists('trade_ewes', $data ?? [], null); + $this->setIfExists('trade_lambs_and_hoggets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['breeding_ewes'] === null) { + $invalidProperties[] = "'breeding_ewes' can't be null"; + } + if ($this->container['ewe_lambs'] === null) { + $invalidProperties[] = "'ewe_lambs' can't be null"; + } + if ($this->container['wether_lambs'] === null) { + $invalidProperties[] = "'wether_lambs' 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 rams + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getRams() + { + return $this->container['rams']; + } + + /** + * Sets rams + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $rams rams + * + * @return self + */ + public function setRams($rams) + { + if (is_null($rams)) { + throw new \InvalidArgumentException('non-nullable rams cannot be null'); + } + $this->container['rams'] = $rams; + + return $this; + } + + /** + * Gets trade_rams + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeRams() + { + return $this->container['trade_rams']; + } + + /** + * Sets trade_rams + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_rams trade_rams + * + * @return self + */ + public function setTradeRams($trade_rams) + { + if (is_null($trade_rams)) { + throw new \InvalidArgumentException('non-nullable trade_rams cannot be null'); + } + $this->container['trade_rams'] = $trade_rams; + + return $this; + } + + /** + * Gets wethers + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getWethers() + { + return $this->container['wethers']; + } + + /** + * Sets wethers + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $wethers wethers + * + * @return self + */ + public function setWethers($wethers) + { + if (is_null($wethers)) { + throw new \InvalidArgumentException('non-nullable wethers cannot be null'); + } + $this->container['wethers'] = $wethers; + + return $this; + } + + /** + * Gets trade_wethers + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeWethers() + { + return $this->container['trade_wethers']; + } + + /** + * Sets trade_wethers + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_wethers trade_wethers + * + * @return self + */ + public function setTradeWethers($trade_wethers) + { + if (is_null($trade_wethers)) { + throw new \InvalidArgumentException('non-nullable trade_wethers cannot be null'); + } + $this->container['trade_wethers'] = $trade_wethers; + + return $this; + } + + /** + * Gets maiden_breeding_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getMaidenBreedingEwes() + { + return $this->container['maiden_breeding_ewes']; + } + + /** + * Sets maiden_breeding_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $maiden_breeding_ewes maiden_breeding_ewes + * + * @return self + */ + public function setMaidenBreedingEwes($maiden_breeding_ewes) + { + if (is_null($maiden_breeding_ewes)) { + throw new \InvalidArgumentException('non-nullable maiden_breeding_ewes cannot be null'); + } + $this->container['maiden_breeding_ewes'] = $maiden_breeding_ewes; + + return $this; + } + + /** + * Gets trade_maiden_breeding_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeMaidenBreedingEwes() + { + return $this->container['trade_maiden_breeding_ewes']; + } + + /** + * Sets trade_maiden_breeding_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_maiden_breeding_ewes trade_maiden_breeding_ewes + * + * @return self + */ + public function setTradeMaidenBreedingEwes($trade_maiden_breeding_ewes) + { + if (is_null($trade_maiden_breeding_ewes)) { + throw new \InvalidArgumentException('non-nullable trade_maiden_breeding_ewes cannot be null'); + } + $this->container['trade_maiden_breeding_ewes'] = $trade_maiden_breeding_ewes; + + return $this; + } + + /** + * Gets breeding_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams + */ + public function getBreedingEwes() + { + return $this->container['breeding_ewes']; + } + + /** + * Sets breeding_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams $breeding_ewes breeding_ewes + * + * @return self + */ + public function setBreedingEwes($breeding_ewes) + { + if (is_null($breeding_ewes)) { + throw new \InvalidArgumentException('non-nullable breeding_ewes cannot be null'); + } + $this->container['breeding_ewes'] = $breeding_ewes; + + return $this; + } + + /** + * Gets trade_breeding_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeBreedingEwes() + { + return $this->container['trade_breeding_ewes']; + } + + /** + * Sets trade_breeding_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_breeding_ewes trade_breeding_ewes + * + * @return self + */ + public function setTradeBreedingEwes($trade_breeding_ewes) + { + if (is_null($trade_breeding_ewes)) { + throw new \InvalidArgumentException('non-nullable trade_breeding_ewes cannot be null'); + } + $this->container['trade_breeding_ewes'] = $trade_breeding_ewes; + + return $this; + } + + /** + * Gets other_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getOtherEwes() + { + return $this->container['other_ewes']; + } + + /** + * Sets other_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $other_ewes other_ewes + * + * @return self + */ + public function setOtherEwes($other_ewes) + { + if (is_null($other_ewes)) { + throw new \InvalidArgumentException('non-nullable other_ewes cannot be null'); + } + $this->container['other_ewes'] = $other_ewes; + + return $this; + } + + /** + * Gets trade_other_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeOtherEwes() + { + return $this->container['trade_other_ewes']; + } + + /** + * Sets trade_other_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_other_ewes trade_other_ewes + * + * @return self + */ + public function setTradeOtherEwes($trade_other_ewes) + { + if (is_null($trade_other_ewes)) { + throw new \InvalidArgumentException('non-nullable trade_other_ewes cannot be null'); + } + $this->container['trade_other_ewes'] = $trade_other_ewes; + + return $this; + } + + /** + * Gets ewe_lambs + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams + */ + public function getEweLambs() + { + return $this->container['ewe_lambs']; + } + + /** + * Sets ewe_lambs + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams $ewe_lambs ewe_lambs + * + * @return self + */ + public function setEweLambs($ewe_lambs) + { + if (is_null($ewe_lambs)) { + throw new \InvalidArgumentException('non-nullable ewe_lambs cannot be null'); + } + $this->container['ewe_lambs'] = $ewe_lambs; + + return $this; + } + + /** + * Gets trade_ewe_lambs + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeEweLambs() + { + return $this->container['trade_ewe_lambs']; + } + + /** + * Sets trade_ewe_lambs + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_ewe_lambs trade_ewe_lambs + * + * @return self + */ + public function setTradeEweLambs($trade_ewe_lambs) + { + if (is_null($trade_ewe_lambs)) { + throw new \InvalidArgumentException('non-nullable trade_ewe_lambs cannot be null'); + } + $this->container['trade_ewe_lambs'] = $trade_ewe_lambs; + + return $this; + } + + /** + * Gets wether_lambs + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams + */ + public function getWetherLambs() + { + return $this->container['wether_lambs']; + } + + /** + * Sets wether_lambs + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams $wether_lambs wether_lambs + * + * @return self + */ + public function setWetherLambs($wether_lambs) + { + if (is_null($wether_lambs)) { + throw new \InvalidArgumentException('non-nullable wether_lambs cannot be null'); + } + $this->container['wether_lambs'] = $wether_lambs; + + return $this; + } + + /** + * Gets trade_wether_lambs + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null + */ + public function getTradeWetherLambs() + { + return $this->container['trade_wether_lambs']; + } + + /** + * Sets trade_wether_lambs + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRams|null $trade_wether_lambs trade_wether_lambs + * + * @return self + */ + public function setTradeWetherLambs($trade_wether_lambs) + { + if (is_null($trade_wether_lambs)) { + throw new \InvalidArgumentException('non-nullable trade_wether_lambs cannot be null'); + } + $this->container['trade_wether_lambs'] = $trade_wether_lambs; + + return $this; + } + + /** + * Gets trade_ewes + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeEwes|null + * @deprecated + */ + public function getTradeEwes() + { + return $this->container['trade_ewes']; + } + + /** + * Sets trade_ewes + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeEwes|null $trade_ewes trade_ewes + * + * @return self + * @deprecated + */ + public function setTradeEwes($trade_ewes) + { + if (is_null($trade_ewes)) { + throw new \InvalidArgumentException('non-nullable trade_ewes cannot be null'); + } + $this->container['trade_ewes'] = $trade_ewes; + + return $this; + } + + /** + * Gets trade_lambs_and_hoggets + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeLambsAndHoggets|null + * @deprecated + */ + public function getTradeLambsAndHoggets() + { + return $this->container['trade_lambs_and_hoggets']; + } + + /** + * Sets trade_lambs_and_hoggets + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesTradeLambsAndHoggets|null $trade_lambs_and_hoggets trade_lambs_and_hoggets + * + * @return self + * @deprecated + */ + public function setTradeLambsAndHoggets($trade_lambs_and_hoggets) + { + if (is_null($trade_lambs_and_hoggets)) { + throw new \InvalidArgumentException('non-nullable trade_lambs_and_hoggets cannot be null'); + } + $this->container['trade_lambs_and_hoggets'] = $trade_lambs_and_hoggets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRams.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRams.php new file mode 100644 index 00000000..e59b442e --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRams.php @@ -0,0 +1,815 @@ + + */ +class PostSheepRequestSheepInnerClassesRams implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_classes_rams'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of sheep shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRamsAutumn.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRamsAutumn.php new file mode 100644 index 00000000..9310a817 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesRamsAutumn.php @@ -0,0 +1,589 @@ + + */ +class PostSheepRequestSheepInnerClassesRamsAutumn implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_classes_rams_autumn'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'head' => 'float', + 'liveweight' => 'float', + 'liveweight_gain' => 'float', + 'crude_protein' => 'float', + 'dry_matter_digestibility' => 'float', + 'feed_availability' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'head' => null, + 'liveweight' => null, + 'liveweight_gain' => null, + 'crude_protein' => null, + 'dry_matter_digestibility' => null, + 'feed_availability' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'head' => false, + 'liveweight' => false, + 'liveweight_gain' => false, + 'crude_protein' => false, + 'dry_matter_digestibility' => false, + 'feed_availability' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'head' => 'head', + 'liveweight' => 'liveweight', + 'liveweight_gain' => 'liveweightGain', + 'crude_protein' => 'crudeProtein', + 'dry_matter_digestibility' => 'dryMatterDigestibility', + 'feed_availability' => 'feedAvailability' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'head' => 'setHead', + 'liveweight' => 'setLiveweight', + 'liveweight_gain' => 'setLiveweightGain', + 'crude_protein' => 'setCrudeProtein', + 'dry_matter_digestibility' => 'setDryMatterDigestibility', + 'feed_availability' => 'setFeedAvailability' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'head' => 'getHead', + 'liveweight' => 'getLiveweight', + 'liveweight_gain' => 'getLiveweightGain', + 'crude_protein' => 'getCrudeProtein', + 'dry_matter_digestibility' => 'getDryMatterDigestibility', + 'feed_availability' => 'getFeedAvailability' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('head', $data ?? [], null); + $this->setIfExists('liveweight', $data ?? [], null); + $this->setIfExists('liveweight_gain', $data ?? [], null); + $this->setIfExists('crude_protein', $data ?? [], null); + $this->setIfExists('dry_matter_digestibility', $data ?? [], null); + $this->setIfExists('feed_availability', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['head'] === null) { + $invalidProperties[] = "'head' can't be null"; + } + if ($this->container['liveweight'] === null) { + $invalidProperties[] = "'liveweight' can't be null"; + } + if ($this->container['liveweight_gain'] === null) { + $invalidProperties[] = "'liveweight_gain' 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 head + * + * @return float + */ + public function getHead() + { + return $this->container['head']; + } + + /** + * Sets head + * + * @param float $head Number of animals (head) + * + * @return self + */ + public function setHead($head) + { + if (is_null($head)) { + throw new \InvalidArgumentException('non-nullable head cannot be null'); + } + $this->container['head'] = $head; + + return $this; + } + + /** + * Gets liveweight + * + * @return float + */ + public function getLiveweight() + { + return $this->container['liveweight']; + } + + /** + * Sets liveweight + * + * @param float $liveweight Average liveweight of animals in kg/head (kilogram per head) + * + * @return self + */ + public function setLiveweight($liveweight) + { + if (is_null($liveweight)) { + throw new \InvalidArgumentException('non-nullable liveweight cannot be null'); + } + $this->container['liveweight'] = $liveweight; + + return $this; + } + + /** + * Gets liveweight_gain + * + * @return float + */ + public function getLiveweightGain() + { + return $this->container['liveweight_gain']; + } + + /** + * Sets liveweight_gain + * + * @param float $liveweight_gain Average liveweight gain in kg/day (kilogram per day) + * + * @return self + */ + public function setLiveweightGain($liveweight_gain) + { + if (is_null($liveweight_gain)) { + throw new \InvalidArgumentException('non-nullable liveweight_gain cannot be null'); + } + $this->container['liveweight_gain'] = $liveweight_gain; + + return $this; + } + + /** + * Gets crude_protein + * + * @return float|null + */ + public function getCrudeProtein() + { + return $this->container['crude_protein']; + } + + /** + * Sets crude_protein + * + * @param float|null $crude_protein Crude protein percent, between 0 and 100 + * + * @return self + */ + public function setCrudeProtein($crude_protein) + { + if (is_null($crude_protein)) { + throw new \InvalidArgumentException('non-nullable crude_protein cannot be null'); + } + $this->container['crude_protein'] = $crude_protein; + + return $this; + } + + /** + * Gets dry_matter_digestibility + * + * @return float|null + */ + public function getDryMatterDigestibility() + { + return $this->container['dry_matter_digestibility']; + } + + /** + * Sets dry_matter_digestibility + * + * @param float|null $dry_matter_digestibility Dry matter digestibility percent, between 0 and 100 + * + * @return self + */ + public function setDryMatterDigestibility($dry_matter_digestibility) + { + if (is_null($dry_matter_digestibility)) { + throw new \InvalidArgumentException('non-nullable dry_matter_digestibility cannot be null'); + } + $this->container['dry_matter_digestibility'] = $dry_matter_digestibility; + + return $this; + } + + /** + * Gets feed_availability + * + * @return float|null + */ + public function getFeedAvailability() + { + return $this->container['feed_availability']; + } + + /** + * Sets feed_availability + * + * @param float|null $feed_availability Feed availability, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setFeedAvailability($feed_availability) + { + if (is_null($feed_availability)) { + throw new \InvalidArgumentException('non-nullable feed_availability cannot be null'); + } + $this->container['feed_availability'] = $feed_availability; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeEwes.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeEwes.php new file mode 100644 index 00000000..99abc24a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeEwes.php @@ -0,0 +1,816 @@ + + */ +class PostSheepRequestSheepInnerClassesTradeEwes implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_classes_tradeEwes'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of sheep shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.php new file mode 100644 index 00000000..a7710012 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.php @@ -0,0 +1,816 @@ + + */ +class PostSheepRequestSheepInnerClassesTradeLambsAndHoggets implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_classes_tradeLambsAndHoggets'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'winter' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'spring' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'summer' => '\OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn', + 'head_shorn' => 'float', + 'wool_shorn' => 'float', + 'clean_wool_yield' => 'float', + 'head_purchased' => 'float', + 'purchased_weight' => 'float', + 'head_sold' => 'float', + 'sale_weight' => 'float', + 'purchases' => '\OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null, + 'head_shorn' => null, + 'wool_shorn' => null, + 'clean_wool_yield' => null, + 'head_purchased' => null, + 'purchased_weight' => null, + 'head_sold' => null, + 'sale_weight' => null, + 'purchases' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false, + 'head_shorn' => false, + 'wool_shorn' => false, + 'clean_wool_yield' => false, + 'head_purchased' => false, + 'purchased_weight' => false, + 'head_sold' => false, + 'sale_weight' => false, + 'purchases' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer', + 'head_shorn' => 'headShorn', + 'wool_shorn' => 'woolShorn', + 'clean_wool_yield' => 'cleanWoolYield', + 'head_purchased' => 'headPurchased', + 'purchased_weight' => 'purchasedWeight', + 'head_sold' => 'headSold', + 'sale_weight' => 'saleWeight', + 'purchases' => 'purchases' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer', + 'head_shorn' => 'setHeadShorn', + 'wool_shorn' => 'setWoolShorn', + 'clean_wool_yield' => 'setCleanWoolYield', + 'head_purchased' => 'setHeadPurchased', + 'purchased_weight' => 'setPurchasedWeight', + 'head_sold' => 'setHeadSold', + 'sale_weight' => 'setSaleWeight', + 'purchases' => 'setPurchases' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer', + 'head_shorn' => 'getHeadShorn', + 'wool_shorn' => 'getWoolShorn', + 'clean_wool_yield' => 'getCleanWoolYield', + 'head_purchased' => 'getHeadPurchased', + 'purchased_weight' => 'getPurchasedWeight', + 'head_sold' => 'getHeadSold', + 'sale_weight' => 'getSaleWeight', + 'purchases' => 'getPurchases' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + $this->setIfExists('head_shorn', $data ?? [], null); + $this->setIfExists('wool_shorn', $data ?? [], null); + $this->setIfExists('clean_wool_yield', $data ?? [], null); + $this->setIfExists('head_purchased', $data ?? [], null); + $this->setIfExists('purchased_weight', $data ?? [], null); + $this->setIfExists('head_sold', $data ?? [], null); + $this->setIfExists('sale_weight', $data ?? [], null); + $this->setIfExists('purchases', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if ($this->container['head_shorn'] === null) { + $invalidProperties[] = "'head_shorn' can't be null"; + } + if ($this->container['wool_shorn'] === null) { + $invalidProperties[] = "'wool_shorn' can't be null"; + } + if ($this->container['clean_wool_yield'] === null) { + $invalidProperties[] = "'clean_wool_yield' can't be null"; + } + if ($this->container['head_sold'] === null) { + $invalidProperties[] = "'head_sold' can't be null"; + } + if ($this->container['sale_weight'] === null) { + $invalidProperties[] = "'sale_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 autumn + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInnerClassesRamsAutumn $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + $this->container['summer'] = $summer; + + return $this; + } + + /** + * Gets head_shorn + * + * @return float + */ + public function getHeadShorn() + { + return $this->container['head_shorn']; + } + + /** + * Sets head_shorn + * + * @param float $head_shorn Number of sheep shorn, in head + * + * @return self + */ + public function setHeadShorn($head_shorn) + { + if (is_null($head_shorn)) { + throw new \InvalidArgumentException('non-nullable head_shorn cannot be null'); + } + $this->container['head_shorn'] = $head_shorn; + + return $this; + } + + /** + * Gets wool_shorn + * + * @return float + */ + public function getWoolShorn() + { + return $this->container['wool_shorn']; + } + + /** + * Sets wool_shorn + * + * @param float $wool_shorn Weight of wool shorn, in kg/head (kilogram per head) + * + * @return self + */ + public function setWoolShorn($wool_shorn) + { + if (is_null($wool_shorn)) { + throw new \InvalidArgumentException('non-nullable wool_shorn cannot be null'); + } + $this->container['wool_shorn'] = $wool_shorn; + + return $this; + } + + /** + * Gets clean_wool_yield + * + * @return float + */ + public function getCleanWoolYield() + { + return $this->container['clean_wool_yield']; + } + + /** + * Sets clean_wool_yield + * + * @param float $clean_wool_yield Percentage of clean wool from weight of yield, from 0 to 100 + * + * @return self + */ + public function setCleanWoolYield($clean_wool_yield) + { + if (is_null($clean_wool_yield)) { + throw new \InvalidArgumentException('non-nullable clean_wool_yield cannot be null'); + } + $this->container['clean_wool_yield'] = $clean_wool_yield; + + return $this; + } + + /** + * Gets head_purchased + * + * @return float|null + * @deprecated + */ + public function getHeadPurchased() + { + return $this->container['head_purchased']; + } + + /** + * Sets head_purchased + * + * @param float|null $head_purchased Number of animals purchased (head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setHeadPurchased($head_purchased) + { + if (is_null($head_purchased)) { + throw new \InvalidArgumentException('non-nullable head_purchased cannot be null'); + } + $this->container['head_purchased'] = $head_purchased; + + return $this; + } + + /** + * Gets purchased_weight + * + * @return float|null + * @deprecated + */ + public function getPurchasedWeight() + { + return $this->container['purchased_weight']; + } + + /** + * Sets purchased_weight + * + * @param float|null $purchased_weight Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead + * + * @return self + * @deprecated + */ + public function setPurchasedWeight($purchased_weight) + { + if (is_null($purchased_weight)) { + throw new \InvalidArgumentException('non-nullable purchased_weight cannot be null'); + } + $this->container['purchased_weight'] = $purchased_weight; + + return $this; + } + + /** + * Gets head_sold + * + * @return float + */ + public function getHeadSold() + { + return $this->container['head_sold']; + } + + /** + * Sets head_sold + * + * @param float $head_sold Number of animals sold (head) + * + * @return self + */ + public function setHeadSold($head_sold) + { + if (is_null($head_sold)) { + throw new \InvalidArgumentException('non-nullable head_sold cannot be null'); + } + $this->container['head_sold'] = $head_sold; + + return $this; + } + + /** + * Gets sale_weight + * + * @return float + */ + public function getSaleWeight() + { + return $this->container['sale_weight']; + } + + /** + * Sets sale_weight + * + * @param float $sale_weight Weight at sale, in liveweight kg/head (kilogram per head) + * + * @return self + */ + public function setSaleWeight($sale_weight) + { + if (is_null($sale_weight)) { + throw new \InvalidArgumentException('non-nullable sale_weight cannot be null'); + } + $this->container['sale_weight'] = $sale_weight; + + return $this; + } + + /** + * Gets purchases + * + * @return \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null + */ + public function getPurchases() + { + return $this->container['purchases']; + } + + /** + * Sets purchases + * + * @param \OpenAPI\Client\Model\PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner[]|null $purchases purchases + * + * @return self + */ + public function setPurchases($purchases) + { + if (is_null($purchases)) { + throw new \InvalidArgumentException('non-nullable purchases cannot be null'); + } + $this->container['purchases'] = $purchases; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerEwesLambing.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerEwesLambing.php new file mode 100644 index 00000000..6f32284c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerEwesLambing.php @@ -0,0 +1,589 @@ + + */ +class PostSheepRequestSheepInnerEwesLambing implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_ewesLambing'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if (($this->container['autumn'] > 1)) { + $invalidProperties[] = "invalid value for 'autumn', must be smaller than or equal to 1."; + } + + if (($this->container['autumn'] < 0)) { + $invalidProperties[] = "invalid value for 'autumn', must be bigger than or equal to 0."; + } + + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if (($this->container['winter'] > 1)) { + $invalidProperties[] = "invalid value for 'winter', must be smaller than or equal to 1."; + } + + if (($this->container['winter'] < 0)) { + $invalidProperties[] = "invalid value for 'winter', must be bigger than or equal to 0."; + } + + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if (($this->container['spring'] > 1)) { + $invalidProperties[] = "invalid value for 'spring', must be smaller than or equal to 1."; + } + + if (($this->container['spring'] < 0)) { + $invalidProperties[] = "invalid value for 'spring', must be bigger than or equal to 0."; + } + + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if (($this->container['summer'] > 1)) { + $invalidProperties[] = "invalid value for 'summer', must be smaller than or equal to 1."; + } + + if (($this->container['summer'] < 0)) { + $invalidProperties[] = "invalid value for 'summer', 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + + if (($autumn > 1)) { + throw new \InvalidArgumentException('invalid value for $autumn when calling PostSheepRequestSheepInnerEwesLambing., must be smaller than or equal to 1.'); + } + if (($autumn < 0)) { + throw new \InvalidArgumentException('invalid value for $autumn when calling PostSheepRequestSheepInnerEwesLambing., must be bigger than or equal to 0.'); + } + + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + + if (($winter > 1)) { + throw new \InvalidArgumentException('invalid value for $winter when calling PostSheepRequestSheepInnerEwesLambing., must be smaller than or equal to 1.'); + } + if (($winter < 0)) { + throw new \InvalidArgumentException('invalid value for $winter when calling PostSheepRequestSheepInnerEwesLambing., must be bigger than or equal to 0.'); + } + + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + + if (($spring > 1)) { + throw new \InvalidArgumentException('invalid value for $spring when calling PostSheepRequestSheepInnerEwesLambing., must be smaller than or equal to 1.'); + } + if (($spring < 0)) { + throw new \InvalidArgumentException('invalid value for $spring when calling PostSheepRequestSheepInnerEwesLambing., must be bigger than or equal to 0.'); + } + + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + + if (($summer > 1)) { + throw new \InvalidArgumentException('invalid value for $summer when calling PostSheepRequestSheepInnerEwesLambing., must be smaller than or equal to 1.'); + } + if (($summer < 0)) { + throw new \InvalidArgumentException('invalid value for $summer when calling PostSheepRequestSheepInnerEwesLambing., must be bigger than or equal to 0.'); + } + + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerSeasonalLambing.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerSeasonalLambing.php new file mode 100644 index 00000000..3f2009be --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestSheepInnerSeasonalLambing.php @@ -0,0 +1,561 @@ + + */ +class PostSheepRequestSheepInnerSeasonalLambing implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_sheep_inner_seasonalLambing'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'autumn' => 'float', + 'winter' => 'float', + 'spring' => 'float', + 'summer' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'autumn' => null, + 'winter' => null, + 'spring' => null, + 'summer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'autumn' => false, + 'winter' => false, + 'spring' => false, + 'summer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'autumn' => 'autumn', + 'winter' => 'winter', + 'spring' => 'spring', + 'summer' => 'summer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'autumn' => 'setAutumn', + 'winter' => 'setWinter', + 'spring' => 'setSpring', + 'summer' => 'setSummer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'autumn' => 'getAutumn', + 'winter' => 'getWinter', + 'spring' => 'getSpring', + 'summer' => 'getSummer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('autumn', $data ?? [], null); + $this->setIfExists('winter', $data ?? [], null); + $this->setIfExists('spring', $data ?? [], null); + $this->setIfExists('summer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['autumn'] === null) { + $invalidProperties[] = "'autumn' can't be null"; + } + if (($this->container['autumn'] < 0)) { + $invalidProperties[] = "invalid value for 'autumn', must be bigger than or equal to 0."; + } + + if ($this->container['winter'] === null) { + $invalidProperties[] = "'winter' can't be null"; + } + if (($this->container['winter'] < 0)) { + $invalidProperties[] = "invalid value for 'winter', must be bigger than or equal to 0."; + } + + if ($this->container['spring'] === null) { + $invalidProperties[] = "'spring' can't be null"; + } + if (($this->container['spring'] < 0)) { + $invalidProperties[] = "invalid value for 'spring', must be bigger than or equal to 0."; + } + + if ($this->container['summer'] === null) { + $invalidProperties[] = "'summer' can't be null"; + } + if (($this->container['summer'] < 0)) { + $invalidProperties[] = "invalid value for 'summer', 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 autumn + * + * @return float + */ + public function getAutumn() + { + return $this->container['autumn']; + } + + /** + * Sets autumn + * + * @param float $autumn autumn + * + * @return self + */ + public function setAutumn($autumn) + { + if (is_null($autumn)) { + throw new \InvalidArgumentException('non-nullable autumn cannot be null'); + } + + if (($autumn < 0)) { + throw new \InvalidArgumentException('invalid value for $autumn when calling PostSheepRequestSheepInnerSeasonalLambing., must be bigger than or equal to 0.'); + } + + $this->container['autumn'] = $autumn; + + return $this; + } + + /** + * Gets winter + * + * @return float + */ + public function getWinter() + { + return $this->container['winter']; + } + + /** + * Sets winter + * + * @param float $winter winter + * + * @return self + */ + public function setWinter($winter) + { + if (is_null($winter)) { + throw new \InvalidArgumentException('non-nullable winter cannot be null'); + } + + if (($winter < 0)) { + throw new \InvalidArgumentException('invalid value for $winter when calling PostSheepRequestSheepInnerSeasonalLambing., must be bigger than or equal to 0.'); + } + + $this->container['winter'] = $winter; + + return $this; + } + + /** + * Gets spring + * + * @return float + */ + public function getSpring() + { + return $this->container['spring']; + } + + /** + * Sets spring + * + * @param float $spring spring + * + * @return self + */ + public function setSpring($spring) + { + if (is_null($spring)) { + throw new \InvalidArgumentException('non-nullable spring cannot be null'); + } + + if (($spring < 0)) { + throw new \InvalidArgumentException('invalid value for $spring when calling PostSheepRequestSheepInnerSeasonalLambing., must be bigger than or equal to 0.'); + } + + $this->container['spring'] = $spring; + + return $this; + } + + /** + * Gets summer + * + * @return float + */ + public function getSummer() + { + return $this->container['summer']; + } + + /** + * Sets summer + * + * @param float $summer summer + * + * @return self + */ + public function setSummer($summer) + { + if (is_null($summer)) { + throw new \InvalidArgumentException('non-nullable summer cannot be null'); + } + + if (($summer < 0)) { + throw new \InvalidArgumentException('invalid value for $summer when calling PostSheepRequestSheepInnerSeasonalLambing., must be bigger than or equal to 0.'); + } + + $this->container['summer'] = $summer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostSheepRequestVegetationInner.php new file mode 100644 index 00000000..a856d829 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepRequestVegetationInner.php @@ -0,0 +1,451 @@ + + */ +class PostSheepRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheep_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'sheep_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'sheep_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'sheep_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'sheep_proportion' => 'sheepProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'sheep_proportion' => 'setSheepProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'sheep_proportion' => 'getSheepProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('sheep_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['sheep_proportion'] === null) { + $invalidProperties[] = "'sheep_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets sheep_proportion + * + * @return float[] + */ + public function getSheepProportion() + { + return $this->container['sheep_proportion']; + } + + /** + * Sets sheep_proportion + * + * @param float[] $sheep_proportion The proportion of the sequestration that is allocated to sheep + * + * @return self + */ + public function setSheepProportion($sheep_proportion) + { + if (is_null($sheep_proportion)) { + throw new \InvalidArgumentException('non-nullable sheep_proportion cannot be null'); + } + $this->container['sheep_proportion'] = $sheep_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200Response.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200Response.php new file mode 100644 index 00000000..f8debb80 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200Response.php @@ -0,0 +1,710 @@ + + */ +class PostSheepbeef200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBeef200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediate', + 'intermediate_beef' => '\OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[]', + 'intermediate_sheep' => '\OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostSheepbeef200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostSheepbeef200ResponseIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'intermediate_beef' => null, + 'intermediate_sheep' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'intermediate_beef' => false, + 'intermediate_sheep' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'intermediate_beef' => 'intermediateBeef', + 'intermediate_sheep' => 'intermediateSheep', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'intermediate_beef' => 'setIntermediateBeef', + 'intermediate_sheep' => 'setIntermediateSheep', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'intermediate_beef' => 'getIntermediateBeef', + 'intermediate_sheep' => 'getIntermediateSheep', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('intermediate_beef', $data ?? [], null); + $this->setIfExists('intermediate_sheep', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['intermediate_beef'] === null) { + $invalidProperties[] = "'intermediate_beef' can't be null"; + } + if ($this->container['intermediate_sheep'] === null) { + $invalidProperties[] = "'intermediate_sheep' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediate + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediate $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets intermediate_beef + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[] + */ + public function getIntermediateBeef() + { + return $this->container['intermediate_beef']; + } + + /** + * Sets intermediate_beef + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInner[] $intermediate_beef intermediate_beef + * + * @return self + */ + public function setIntermediateBeef($intermediate_beef) + { + if (is_null($intermediate_beef)) { + throw new \InvalidArgumentException('non-nullable intermediate_beef cannot be null'); + } + $this->container['intermediate_beef'] = $intermediate_beef; + + return $this; + } + + /** + * Gets intermediate_sheep + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[] + */ + public function getIntermediateSheep() + { + return $this->container['intermediate_sheep']; + } + + /** + * Sets intermediate_sheep + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInner[] $intermediate_sheep intermediate_sheep + * + * @return self + */ + public function setIntermediateSheep($intermediate_sheep) + { + if (is_null($intermediate_sheep)) { + throw new \InvalidArgumentException('non-nullable intermediate_sheep cannot be null'); + } + $this->container['intermediate_sheep'] = $intermediate_sheep; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostSheepbeef200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostSheepbeef200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSheepbeef200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSheepbeef200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntensities.php new file mode 100644 index 00000000..414b6db6 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntensities.php @@ -0,0 +1,709 @@ + + */ +class PostSheepbeef200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'beef_including_sequestration' => 'float', + 'beef_excluding_sequestration' => 'float', + 'liveweight_beef_produced_kg' => 'float', + 'wool_including_sequestration' => 'float', + 'wool_excluding_sequestration' => 'float', + 'sheep_meat_breeding_including_sequestration' => 'float', + 'sheep_meat_breeding_excluding_sequestration' => 'float', + 'wool_produced_kg' => 'float', + 'sheep_meat_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'beef_including_sequestration' => null, + 'beef_excluding_sequestration' => null, + 'liveweight_beef_produced_kg' => null, + 'wool_including_sequestration' => null, + 'wool_excluding_sequestration' => null, + 'sheep_meat_breeding_including_sequestration' => null, + 'sheep_meat_breeding_excluding_sequestration' => null, + 'wool_produced_kg' => null, + 'sheep_meat_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'beef_including_sequestration' => false, + 'beef_excluding_sequestration' => false, + 'liveweight_beef_produced_kg' => false, + 'wool_including_sequestration' => false, + 'wool_excluding_sequestration' => false, + 'sheep_meat_breeding_including_sequestration' => false, + 'sheep_meat_breeding_excluding_sequestration' => false, + 'wool_produced_kg' => false, + 'sheep_meat_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'beef_including_sequestration' => 'beefIncludingSequestration', + 'beef_excluding_sequestration' => 'beefExcludingSequestration', + 'liveweight_beef_produced_kg' => 'liveweightBeefProducedKg', + 'wool_including_sequestration' => 'woolIncludingSequestration', + 'wool_excluding_sequestration' => 'woolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'sheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'sheepMeatBreedingExcludingSequestration', + 'wool_produced_kg' => 'woolProducedKg', + 'sheep_meat_produced_kg' => 'sheepMeatProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'beef_including_sequestration' => 'setBeefIncludingSequestration', + 'beef_excluding_sequestration' => 'setBeefExcludingSequestration', + 'liveweight_beef_produced_kg' => 'setLiveweightBeefProducedKg', + 'wool_including_sequestration' => 'setWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'setWoolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'setSheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'setSheepMeatBreedingExcludingSequestration', + 'wool_produced_kg' => 'setWoolProducedKg', + 'sheep_meat_produced_kg' => 'setSheepMeatProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'beef_including_sequestration' => 'getBeefIncludingSequestration', + 'beef_excluding_sequestration' => 'getBeefExcludingSequestration', + 'liveweight_beef_produced_kg' => 'getLiveweightBeefProducedKg', + 'wool_including_sequestration' => 'getWoolIncludingSequestration', + 'wool_excluding_sequestration' => 'getWoolExcludingSequestration', + 'sheep_meat_breeding_including_sequestration' => 'getSheepMeatBreedingIncludingSequestration', + 'sheep_meat_breeding_excluding_sequestration' => 'getSheepMeatBreedingExcludingSequestration', + 'wool_produced_kg' => 'getWoolProducedKg', + 'sheep_meat_produced_kg' => 'getSheepMeatProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('beef_including_sequestration', $data ?? [], null); + $this->setIfExists('beef_excluding_sequestration', $data ?? [], null); + $this->setIfExists('liveweight_beef_produced_kg', $data ?? [], null); + $this->setIfExists('wool_including_sequestration', $data ?? [], null); + $this->setIfExists('wool_excluding_sequestration', $data ?? [], null); + $this->setIfExists('sheep_meat_breeding_including_sequestration', $data ?? [], null); + $this->setIfExists('sheep_meat_breeding_excluding_sequestration', $data ?? [], null); + $this->setIfExists('wool_produced_kg', $data ?? [], null); + $this->setIfExists('sheep_meat_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['beef_including_sequestration'] === null) { + $invalidProperties[] = "'beef_including_sequestration' can't be null"; + } + if ($this->container['beef_excluding_sequestration'] === null) { + $invalidProperties[] = "'beef_excluding_sequestration' can't be null"; + } + if ($this->container['liveweight_beef_produced_kg'] === null) { + $invalidProperties[] = "'liveweight_beef_produced_kg' can't be null"; + } + if ($this->container['wool_including_sequestration'] === null) { + $invalidProperties[] = "'wool_including_sequestration' can't be null"; + } + if ($this->container['wool_excluding_sequestration'] === null) { + $invalidProperties[] = "'wool_excluding_sequestration' can't be null"; + } + if ($this->container['sheep_meat_breeding_including_sequestration'] === null) { + $invalidProperties[] = "'sheep_meat_breeding_including_sequestration' can't be null"; + } + if ($this->container['sheep_meat_breeding_excluding_sequestration'] === null) { + $invalidProperties[] = "'sheep_meat_breeding_excluding_sequestration' can't be null"; + } + if ($this->container['wool_produced_kg'] === null) { + $invalidProperties[] = "'wool_produced_kg' can't be null"; + } + if ($this->container['sheep_meat_produced_kg'] === null) { + $invalidProperties[] = "'sheep_meat_produced_kg' 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 beef_including_sequestration + * + * @return float + */ + public function getBeefIncludingSequestration() + { + return $this->container['beef_including_sequestration']; + } + + /** + * Sets beef_including_sequestration + * + * @param float $beef_including_sequestration Beef including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefIncludingSequestration($beef_including_sequestration) + { + if (is_null($beef_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_including_sequestration cannot be null'); + } + $this->container['beef_including_sequestration'] = $beef_including_sequestration; + + return $this; + } + + /** + * Gets beef_excluding_sequestration + * + * @return float + */ + public function getBeefExcludingSequestration() + { + return $this->container['beef_excluding_sequestration']; + } + + /** + * Sets beef_excluding_sequestration + * + * @param float $beef_excluding_sequestration Beef excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setBeefExcludingSequestration($beef_excluding_sequestration) + { + if (is_null($beef_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable beef_excluding_sequestration cannot be null'); + } + $this->container['beef_excluding_sequestration'] = $beef_excluding_sequestration; + + return $this; + } + + /** + * Gets liveweight_beef_produced_kg + * + * @return float + */ + public function getLiveweightBeefProducedKg() + { + return $this->container['liveweight_beef_produced_kg']; + } + + /** + * Sets liveweight_beef_produced_kg + * + * @param float $liveweight_beef_produced_kg Liveweight produced in kg + * + * @return self + */ + public function setLiveweightBeefProducedKg($liveweight_beef_produced_kg) + { + if (is_null($liveweight_beef_produced_kg)) { + throw new \InvalidArgumentException('non-nullable liveweight_beef_produced_kg cannot be null'); + } + $this->container['liveweight_beef_produced_kg'] = $liveweight_beef_produced_kg; + + return $this; + } + + /** + * Gets wool_including_sequestration + * + * @return float + */ + public function getWoolIncludingSequestration() + { + return $this->container['wool_including_sequestration']; + } + + /** + * Sets wool_including_sequestration + * + * @param float $wool_including_sequestration Wool production including carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolIncludingSequestration($wool_including_sequestration) + { + if (is_null($wool_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_including_sequestration cannot be null'); + } + $this->container['wool_including_sequestration'] = $wool_including_sequestration; + + return $this; + } + + /** + * Gets wool_excluding_sequestration + * + * @return float + */ + public function getWoolExcludingSequestration() + { + return $this->container['wool_excluding_sequestration']; + } + + /** + * Sets wool_excluding_sequestration + * + * @param float $wool_excluding_sequestration Wool production excluding carbon sequestration, in kg-CO2e/kg greasy + * + * @return self + */ + public function setWoolExcludingSequestration($wool_excluding_sequestration) + { + if (is_null($wool_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable wool_excluding_sequestration cannot be null'); + } + $this->container['wool_excluding_sequestration'] = $wool_excluding_sequestration; + + return $this; + } + + /** + * Gets sheep_meat_breeding_including_sequestration + * + * @return float + */ + public function getSheepMeatBreedingIncludingSequestration() + { + return $this->container['sheep_meat_breeding_including_sequestration']; + } + + /** + * Sets sheep_meat_breeding_including_sequestration + * + * @param float $sheep_meat_breeding_including_sequestration Sheep meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setSheepMeatBreedingIncludingSequestration($sheep_meat_breeding_including_sequestration) + { + if (is_null($sheep_meat_breeding_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_breeding_including_sequestration cannot be null'); + } + $this->container['sheep_meat_breeding_including_sequestration'] = $sheep_meat_breeding_including_sequestration; + + return $this; + } + + /** + * Gets sheep_meat_breeding_excluding_sequestration + * + * @return float + */ + public function getSheepMeatBreedingExcludingSequestration() + { + return $this->container['sheep_meat_breeding_excluding_sequestration']; + } + + /** + * Sets sheep_meat_breeding_excluding_sequestration + * + * @param float $sheep_meat_breeding_excluding_sequestration Sheep meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight + * + * @return self + */ + public function setSheepMeatBreedingExcludingSequestration($sheep_meat_breeding_excluding_sequestration) + { + if (is_null($sheep_meat_breeding_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_breeding_excluding_sequestration cannot be null'); + } + $this->container['sheep_meat_breeding_excluding_sequestration'] = $sheep_meat_breeding_excluding_sequestration; + + return $this; + } + + /** + * Gets wool_produced_kg + * + * @return float + */ + public function getWoolProducedKg() + { + return $this->container['wool_produced_kg']; + } + + /** + * Sets wool_produced_kg + * + * @param float $wool_produced_kg Greasy wool produced in kg + * + * @return self + */ + public function setWoolProducedKg($wool_produced_kg) + { + if (is_null($wool_produced_kg)) { + throw new \InvalidArgumentException('non-nullable wool_produced_kg cannot be null'); + } + $this->container['wool_produced_kg'] = $wool_produced_kg; + + return $this; + } + + /** + * Gets sheep_meat_produced_kg + * + * @return float + */ + public function getSheepMeatProducedKg() + { + return $this->container['sheep_meat_produced_kg']; + } + + /** + * Sets sheep_meat_produced_kg + * + * @param float $sheep_meat_produced_kg Sheep meat produced in kg liveweight + * + * @return self + */ + public function setSheepMeatProducedKg($sheep_meat_produced_kg) + { + if (is_null($sheep_meat_produced_kg)) { + throw new \InvalidArgumentException('non-nullable sheep_meat_produced_kg cannot be null'); + } + $this->container['sheep_meat_produced_kg'] = $sheep_meat_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediate.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediate.php new file mode 100644 index 00000000..93f872a9 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediate.php @@ -0,0 +1,451 @@ + + */ +class PostSheepbeef200ResponseIntermediate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response_intermediate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'beef' => '\OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateBeef', + 'sheep' => '\OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateSheep' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'beef' => null, + 'sheep' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'beef' => false, + 'sheep' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'beef' => 'beef', + 'sheep' => 'sheep' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'beef' => 'setBeef', + 'sheep' => 'setSheep' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'beef' => 'getBeef', + 'sheep' => 'getSheep' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('beef', $data ?? [], null); + $this->setIfExists('sheep', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['beef'] === null) { + $invalidProperties[] = "'beef' can't be null"; + } + if ($this->container['sheep'] === null) { + $invalidProperties[] = "'sheep' 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 beef + * + * @return \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateBeef + */ + public function getBeef() + { + return $this->container['beef']; + } + + /** + * Sets beef + * + * @param \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateBeef $beef beef + * + * @return self + */ + public function setBeef($beef) + { + if (is_null($beef)) { + throw new \InvalidArgumentException('non-nullable beef cannot be null'); + } + $this->container['beef'] = $beef; + + return $this; + } + + /** + * Gets sheep + * + * @return \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateSheep + */ + public function getSheep() + { + return $this->container['sheep']; + } + + /** + * Sets sheep + * + * @param \OpenAPI\Client\Model\PostSheepbeef200ResponseIntermediateSheep $sheep sheep + * + * @return self + */ + public function setSheep($sheep) + { + if (is_null($sheep)) { + throw new \InvalidArgumentException('non-nullable sheep cannot be null'); + } + $this->container['sheep'] = $sheep; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateBeef.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateBeef.php new file mode 100644 index 00000000..5a46d6e9 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateBeef.php @@ -0,0 +1,599 @@ + + */ +class PostSheepbeef200ResponseIntermediateBeef implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response_intermediate_beef'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBeef200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => 'float', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateSheep.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateSheep.php new file mode 100644 index 00000000..14ac5d47 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseIntermediateSheep.php @@ -0,0 +1,599 @@ + + */ +class PostSheepbeef200ResponseIntermediateSheep implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response_intermediate_sheep'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostBeef200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostBeef200ResponseScope3', + 'carbon_sequestration' => 'float', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostBeef200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostBeef200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSheep200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseNet.php new file mode 100644 index 00000000..f3f817a4 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeef200ResponseNet.php @@ -0,0 +1,487 @@ + + */ +class PostSheepbeef200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'beef' => 'float', + 'sheep' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'beef' => null, + 'sheep' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'beef' => false, + 'sheep' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'beef' => 'beef', + 'sheep' => 'sheep' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'beef' => 'setBeef', + 'sheep' => 'setSheep' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'beef' => 'getBeef', + 'sheep' => 'getSheep' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('beef', $data ?? [], null); + $this->setIfExists('sheep', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['beef'] === null) { + $invalidProperties[] = "'beef' can't be null"; + } + if ($this->container['sheep'] === null) { + $invalidProperties[] = "'sheep' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total net emissions of this activity, in tonnes-CO2e/year + * + * @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 beef + * + * @return float + */ + public function getBeef() + { + return $this->container['beef']; + } + + /** + * Sets beef + * + * @param float $beef Net emissions of beef, in tonnes-CO2e/year + * + * @return self + */ + public function setBeef($beef) + { + if (is_null($beef)) { + throw new \InvalidArgumentException('non-nullable beef cannot be null'); + } + $this->container['beef'] = $beef; + + return $this; + } + + /** + * Gets sheep + * + * @return float + */ + public function getSheep() + { + return $this->container['sheep']; + } + + /** + * Sets sheep + * + * @param float $sheep Net emissions of sheep, in tonnes-CO2e/year + * + * @return self + */ + public function setSheep($sheep) + { + if (is_null($sheep)) { + throw new \InvalidArgumentException('non-nullable sheep cannot be null'); + } + $this->container['sheep'] = $sheep; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequest.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequest.php new file mode 100644 index 00000000..a15ff132 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequest.php @@ -0,0 +1,684 @@ + + */ +class PostSheepbeefRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'north_of_tropic_of_capricorn' => 'bool', + 'rainfall_above600' => 'bool', + 'beef' => '\OpenAPI\Client\Model\PostBeefRequestBeefInner[]', + 'sheep' => '\OpenAPI\Client\Model\PostSheepRequestSheepInner[]', + 'burning' => '\OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning[]', + 'vegetation' => '\OpenAPI\Client\Model\PostSheepbeefRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'north_of_tropic_of_capricorn' => null, + 'rainfall_above600' => null, + 'beef' => null, + 'sheep' => null, + 'burning' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'north_of_tropic_of_capricorn' => false, + 'rainfall_above600' => false, + 'beef' => false, + 'sheep' => false, + 'burning' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'north_of_tropic_of_capricorn' => 'northOfTropicOfCapricorn', + 'rainfall_above600' => 'rainfallAbove600', + 'beef' => 'beef', + 'sheep' => 'sheep', + 'burning' => 'burning', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'north_of_tropic_of_capricorn' => 'setNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'setRainfallAbove600', + 'beef' => 'setBeef', + 'sheep' => 'setSheep', + 'burning' => 'setBurning', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'north_of_tropic_of_capricorn' => 'getNorthOfTropicOfCapricorn', + 'rainfall_above600' => 'getRainfallAbove600', + 'beef' => 'getBeef', + 'sheep' => 'getSheep', + 'burning' => 'getBurning', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('north_of_tropic_of_capricorn', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('beef', $data ?? [], null); + $this->setIfExists('sheep', $data ?? [], null); + $this->setIfExists('burning', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['north_of_tropic_of_capricorn'] === null) { + $invalidProperties[] = "'north_of_tropic_of_capricorn' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['beef'] === null) { + $invalidProperties[] = "'beef' can't be null"; + } + if ($this->container['sheep'] === null) { + $invalidProperties[] = "'sheep' can't be null"; + } + if ($this->container['burning'] === null) { + $invalidProperties[] = "'burning' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets north_of_tropic_of_capricorn + * + * @return bool + */ + public function getNorthOfTropicOfCapricorn() + { + return $this->container['north_of_tropic_of_capricorn']; + } + + /** + * Sets north_of_tropic_of_capricorn + * + * @param bool $north_of_tropic_of_capricorn Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude + * + * @return self + */ + public function setNorthOfTropicOfCapricorn($north_of_tropic_of_capricorn) + { + if (is_null($north_of_tropic_of_capricorn)) { + throw new \InvalidArgumentException('non-nullable north_of_tropic_of_capricorn cannot be null'); + } + $this->container['north_of_tropic_of_capricorn'] = $north_of_tropic_of_capricorn; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets beef + * + * @return \OpenAPI\Client\Model\PostBeefRequestBeefInner[] + */ + public function getBeef() + { + return $this->container['beef']; + } + + /** + * Sets beef + * + * @param \OpenAPI\Client\Model\PostBeefRequestBeefInner[] $beef beef + * + * @return self + */ + public function setBeef($beef) + { + if (is_null($beef)) { + throw new \InvalidArgumentException('non-nullable beef cannot be null'); + } + $this->container['beef'] = $beef; + + return $this; + } + + /** + * Gets sheep + * + * @return \OpenAPI\Client\Model\PostSheepRequestSheepInner[] + */ + public function getSheep() + { + return $this->container['sheep']; + } + + /** + * Sets sheep + * + * @param \OpenAPI\Client\Model\PostSheepRequestSheepInner[] $sheep sheep + * + * @return self + */ + public function setSheep($sheep) + { + if (is_null($sheep)) { + throw new \InvalidArgumentException('non-nullable sheep cannot be null'); + } + $this->container['sheep'] = $sheep; + + return $this; + } + + /** + * Gets burning + * + * @return \OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning[] + */ + public function getBurning() + { + return $this->container['burning']; + } + + /** + * Sets burning + * + * @param \OpenAPI\Client\Model\PostBeefRequestBurningInnerBurning[] $burning burning + * + * @return self + */ + public function setBurning($burning) + { + if (is_null($burning)) { + throw new \InvalidArgumentException('non-nullable burning cannot be null'); + } + $this->container['burning'] = $burning; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostSheepbeefRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostSheepbeefRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequestVegetationInner.php new file mode 100644 index 00000000..97d5c346 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSheepbeefRequestVegetationInner.php @@ -0,0 +1,488 @@ + + */ +class PostSheepbeefRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sheepbeef_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'beef_proportion' => 'float[]', + 'sheep_proportion' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'beef_proportion' => null, + 'sheep_proportion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'beef_proportion' => false, + 'sheep_proportion' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'beef_proportion' => 'beefProportion', + 'sheep_proportion' => 'sheepProportion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'beef_proportion' => 'setBeefProportion', + 'sheep_proportion' => 'setSheepProportion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'beef_proportion' => 'getBeefProportion', + 'sheep_proportion' => 'getSheepProportion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('beef_proportion', $data ?? [], null); + $this->setIfExists('sheep_proportion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['beef_proportion'] === null) { + $invalidProperties[] = "'beef_proportion' can't be null"; + } + if ($this->container['sheep_proportion'] === null) { + $invalidProperties[] = "'sheep_proportion' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets beef_proportion + * + * @return float[] + */ + public function getBeefProportion() + { + return $this->container['beef_proportion']; + } + + /** + * Sets beef_proportion + * + * @param float[] $beef_proportion The proportion of the sequestration that is allocated to beef + * + * @return self + */ + public function setBeefProportion($beef_proportion) + { + if (is_null($beef_proportion)) { + throw new \InvalidArgumentException('non-nullable beef_proportion cannot be null'); + } + $this->container['beef_proportion'] = $beef_proportion; + + return $this; + } + + /** + * Gets sheep_proportion + * + * @return float[] + */ + public function getSheepProportion() + { + return $this->container['sheep_proportion']; + } + + /** + * Sets sheep_proportion + * + * @param float[] $sheep_proportion The proportion of the sequestration that is allocated to sheep + * + * @return self + */ + public function setSheepProportion($sheep_proportion) + { + if (is_null($sheep_proportion)) { + throw new \InvalidArgumentException('non-nullable sheep_proportion cannot be null'); + } + $this->container['sheep_proportion'] = $sheep_proportion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSugar200Response.php b/examples/php-api-client/api-client/lib/Model/PostSugar200Response.php new file mode 100644 index 00000000..fd906719 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSugar200Response.php @@ -0,0 +1,636 @@ + + */ +class PostSugar200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sugar_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostSugar200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostCotton200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities[] $intensities Emissions intensity for each crop (in order), in t-CO2e/t crop + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInner.php new file mode 100644 index 00000000..96208ac2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostSugar200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sugar_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostCotton200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostCotton200ResponseScope3', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostCotton200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostCotton200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostSugar200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..a1fb27b8 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSugar200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostSugar200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sugar_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sugar_excluding_sequestration' => 'float', + 'sugar_including_sequestration' => 'float', + 'sugar_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sugar_excluding_sequestration' => null, + 'sugar_including_sequestration' => null, + 'sugar_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sugar_excluding_sequestration' => false, + 'sugar_including_sequestration' => false, + 'sugar_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sugar_excluding_sequestration' => 'sugarExcludingSequestration', + 'sugar_including_sequestration' => 'sugarIncludingSequestration', + 'sugar_produced_kg' => 'sugarProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sugar_excluding_sequestration' => 'setSugarExcludingSequestration', + 'sugar_including_sequestration' => 'setSugarIncludingSequestration', + 'sugar_produced_kg' => 'setSugarProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sugar_excluding_sequestration' => 'getSugarExcludingSequestration', + 'sugar_including_sequestration' => 'getSugarIncludingSequestration', + 'sugar_produced_kg' => 'getSugarProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('sugar_excluding_sequestration', $data ?? [], null); + $this->setIfExists('sugar_including_sequestration', $data ?? [], null); + $this->setIfExists('sugar_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['sugar_excluding_sequestration'] === null) { + $invalidProperties[] = "'sugar_excluding_sequestration' can't be null"; + } + if ($this->container['sugar_including_sequestration'] === null) { + $invalidProperties[] = "'sugar_including_sequestration' can't be null"; + } + if ($this->container['sugar_produced_kg'] === null) { + $invalidProperties[] = "'sugar_produced_kg' 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 sugar_excluding_sequestration + * + * @return float + */ + public function getSugarExcludingSequestration() + { + return $this->container['sugar_excluding_sequestration']; + } + + /** + * Sets sugar_excluding_sequestration + * + * @param float $sugar_excluding_sequestration Sugar emissions intensity excluding sequestration, in kg-CO2e/kg sugar + * + * @return self + */ + public function setSugarExcludingSequestration($sugar_excluding_sequestration) + { + if (is_null($sugar_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable sugar_excluding_sequestration cannot be null'); + } + $this->container['sugar_excluding_sequestration'] = $sugar_excluding_sequestration; + + return $this; + } + + /** + * Gets sugar_including_sequestration + * + * @return float + */ + public function getSugarIncludingSequestration() + { + return $this->container['sugar_including_sequestration']; + } + + /** + * Sets sugar_including_sequestration + * + * @param float $sugar_including_sequestration Sugar emissions intensity including sequestration, in kg-CO2e/kg sugar + * + * @return self + */ + public function setSugarIncludingSequestration($sugar_including_sequestration) + { + if (is_null($sugar_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable sugar_including_sequestration cannot be null'); + } + $this->container['sugar_including_sequestration'] = $sugar_including_sequestration; + + return $this; + } + + /** + * Gets sugar_produced_kg + * + * @return float + */ + public function getSugarProducedKg() + { + return $this->container['sugar_produced_kg']; + } + + /** + * Sets sugar_produced_kg + * + * @param float $sugar_produced_kg Sugar produced in kg + * + * @return self + */ + public function setSugarProducedKg($sugar_produced_kg) + { + if (is_null($sugar_produced_kg)) { + throw new \InvalidArgumentException('non-nullable sugar_produced_kg cannot be null'); + } + $this->container['sugar_produced_kg'] = $sugar_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSugarRequest.php b/examples/php-api-client/api-client/lib/Model/PostSugarRequest.php new file mode 100644 index 00000000..ac24d736 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSugarRequest.php @@ -0,0 +1,626 @@ + + */ +class PostSugarRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sugar_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'state' => 'string', + 'crops' => '\OpenAPI\Client\Model\PostSugarRequestCropsInner[]', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'vegetation' => '\OpenAPI\Client\Model\PostCottonRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'state' => null, + 'crops' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'state' => false, + 'crops' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'state' => 'state', + 'crops' => 'crops', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'state' => 'setState', + 'crops' => 'setCrops', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'state' => 'getState', + 'crops' => 'getCrops', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('crops', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['crops'] === null) { + $invalidProperties[] = "'crops' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets crops + * + * @return \OpenAPI\Client\Model\PostSugarRequestCropsInner[] + */ + public function getCrops() + { + return $this->container['crops']; + } + + /** + * Sets crops + * + * @param \OpenAPI\Client\Model\PostSugarRequestCropsInner[] $crops crops + * + * @return self + */ + public function setCrops($crops) + { + if (is_null($crops)) { + throw new \InvalidArgumentException('non-nullable crops cannot be null'); + } + $this->container['crops'] = $crops; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostSugarRequest., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostSugarRequest., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostCottonRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostSugarRequestCropsInner.php b/examples/php-api-client/api-client/lib/Model/PostSugarRequestCropsInner.php new file mode 100644 index 00000000..796cdaab --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostSugarRequestCropsInner.php @@ -0,0 +1,1272 @@ + + */ +class PostSugarRequestCropsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_sugar_request_crops_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'production_system' => 'string', + 'average_cane_yield' => 'float', + 'percent_milled_cane_yield' => 'float', + 'area_sown' => 'float', + 'non_urea_nitrogen' => 'float', + 'urea_application' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'rainfall_above600' => 'bool', + 'fraction_of_annual_crop_burnt' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_allocation' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'diesel_use' => 'float', + 'petrol_use' => 'float', + 'lpg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'production_system' => null, + 'average_cane_yield' => null, + 'percent_milled_cane_yield' => null, + 'area_sown' => null, + 'non_urea_nitrogen' => null, + 'urea_application' => null, + 'urea_ammonium_nitrate' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'rainfall_above600' => null, + 'fraction_of_annual_crop_burnt' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_allocation' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'diesel_use' => null, + 'petrol_use' => null, + 'lpg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'production_system' => false, + 'average_cane_yield' => false, + 'percent_milled_cane_yield' => false, + 'area_sown' => false, + 'non_urea_nitrogen' => false, + 'urea_application' => false, + 'urea_ammonium_nitrate' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'rainfall_above600' => false, + 'fraction_of_annual_crop_burnt' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_allocation' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'diesel_use' => false, + 'petrol_use' => false, + 'lpg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'production_system' => 'productionSystem', + 'average_cane_yield' => 'averageCaneYield', + 'percent_milled_cane_yield' => 'percentMilledCaneYield', + 'area_sown' => 'areaSown', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'urea_application' => 'ureaApplication', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'rainfall_above600' => 'rainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'fractionOfAnnualCropBurnt', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_allocation' => 'electricityAllocation', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'diesel_use' => 'dieselUse', + 'petrol_use' => 'petrolUse', + 'lpg' => 'lpg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'production_system' => 'setProductionSystem', + 'average_cane_yield' => 'setAverageCaneYield', + 'percent_milled_cane_yield' => 'setPercentMilledCaneYield', + 'area_sown' => 'setAreaSown', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'urea_application' => 'setUreaApplication', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'rainfall_above600' => 'setRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'setFractionOfAnnualCropBurnt', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'setElectricityAllocation', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'diesel_use' => 'setDieselUse', + 'petrol_use' => 'setPetrolUse', + 'lpg' => 'setLpg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'production_system' => 'getProductionSystem', + 'average_cane_yield' => 'getAverageCaneYield', + 'percent_milled_cane_yield' => 'getPercentMilledCaneYield', + 'area_sown' => 'getAreaSown', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'urea_application' => 'getUreaApplication', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'rainfall_above600' => 'getRainfallAbove600', + 'fraction_of_annual_crop_burnt' => 'getFractionOfAnnualCropBurnt', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_allocation' => 'getElectricityAllocation', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'diesel_use' => 'getDieselUse', + 'petrol_use' => 'getPetrolUse', + 'lpg' => 'getLpg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const PRODUCTION_SYSTEM_NON_IRRIGATED_CROP = 'Non-irrigated crop'; + public const PRODUCTION_SYSTEM_IRRIGATED_CROP = 'Irrigated crop'; + public const PRODUCTION_SYSTEM_SUGAR_CANE = 'Sugar cane'; + public const PRODUCTION_SYSTEM_COTTON = 'Cotton'; + public const PRODUCTION_SYSTEM_HORTICULTURE = 'Horticulture'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductionSystemAllowableValues() + { + return [ + self::PRODUCTION_SYSTEM_NON_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_IRRIGATED_CROP, + self::PRODUCTION_SYSTEM_SUGAR_CANE, + self::PRODUCTION_SYSTEM_COTTON, + self::PRODUCTION_SYSTEM_HORTICULTURE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('production_system', $data ?? [], null); + $this->setIfExists('average_cane_yield', $data ?? [], null); + $this->setIfExists('percent_milled_cane_yield', $data ?? [], null); + $this->setIfExists('area_sown', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], null); + $this->setIfExists('phosphorus_application', $data ?? [], null); + $this->setIfExists('potassium_application', $data ?? [], null); + $this->setIfExists('sulfur_application', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('fraction_of_annual_crop_burnt', $data ?? [], null); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_allocation', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('diesel_use', $data ?? [], null); + $this->setIfExists('petrol_use', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['production_system'] === null) { + $invalidProperties[] = "'production_system' can't be null"; + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!is_null($this->container['production_system']) && !in_array($this->container['production_system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'production_system', must be one of '%s'", + $this->container['production_system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['average_cane_yield'] === null) { + $invalidProperties[] = "'average_cane_yield' can't be null"; + } + if ($this->container['area_sown'] === null) { + $invalidProperties[] = "'area_sown' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['fraction_of_annual_crop_burnt'] === null) { + $invalidProperties[] = "'fraction_of_annual_crop_burnt' can't be null"; + } + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_allocation'] === null) { + $invalidProperties[] = "'electricity_allocation' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['diesel_use'] === null) { + $invalidProperties[] = "'diesel_use' can't be null"; + } + if ($this->container['petrol_use'] === null) { + $invalidProperties[] = "'petrol_use' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets production_system + * + * @return string + */ + public function getProductionSystem() + { + return $this->container['production_system']; + } + + /** + * Sets production_system + * + * @param string $production_system Production system of this crop + * + * @return self + */ + public function setProductionSystem($production_system) + { + if (is_null($production_system)) { + throw new \InvalidArgumentException('non-nullable production_system cannot be null'); + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!in_array($production_system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'production_system', must be one of '%s'", + $production_system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['production_system'] = $production_system; + + return $this; + } + + /** + * Gets average_cane_yield + * + * @return float + */ + public function getAverageCaneYield() + { + return $this->container['average_cane_yield']; + } + + /** + * Sets average_cane_yield + * + * @param float $average_cane_yield Average cane/crop yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageCaneYield($average_cane_yield) + { + if (is_null($average_cane_yield)) { + throw new \InvalidArgumentException('non-nullable average_cane_yield cannot be null'); + } + $this->container['average_cane_yield'] = $average_cane_yield; + + return $this; + } + + /** + * Gets percent_milled_cane_yield + * + * @return float|null + */ + public function getPercentMilledCaneYield() + { + return $this->container['percent_milled_cane_yield']; + } + + /** + * Sets percent_milled_cane_yield + * + * @param float|null $percent_milled_cane_yield Percentage of cane yield that becomes milled sugar, from 0 to 1 + * + * @return self + */ + public function setPercentMilledCaneYield($percent_milled_cane_yield) + { + if (is_null($percent_milled_cane_yield)) { + throw new \InvalidArgumentException('non-nullable percent_milled_cane_yield cannot be null'); + } + $this->container['percent_milled_cane_yield'] = $percent_milled_cane_yield; + + return $this; + } + + /** + * Gets area_sown + * + * @return float + */ + public function getAreaSown() + { + return $this->container['area_sown']; + } + + /** + * Sets area_sown + * + * @param float $area_sown Area sown, in ha (hectares) + * + * @return self + */ + public function setAreaSown($area_sown) + { + if (is_null($area_sown)) { + throw new \InvalidArgumentException('non-nullable area_sown cannot be null'); + } + $this->container['area_sown'] = $area_sown; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets fraction_of_annual_crop_burnt + * + * @return float + */ + public function getFractionOfAnnualCropBurnt() + { + return $this->container['fraction_of_annual_crop_burnt']; + } + + /** + * Sets fraction_of_annual_crop_burnt + * + * @param float $fraction_of_annual_crop_burnt Fraction of annual production of crop that is burnt, from 0 to 1 + * + * @return self + */ + public function setFractionOfAnnualCropBurnt($fraction_of_annual_crop_burnt) + { + if (is_null($fraction_of_annual_crop_burnt)) { + throw new \InvalidArgumentException('non-nullable fraction_of_annual_crop_burnt cannot be null'); + } + $this->container['fraction_of_annual_crop_burnt'] = $fraction_of_annual_crop_burnt; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_allocation + * + * @return float + */ + public function getElectricityAllocation() + { + return $this->container['electricity_allocation']; + } + + /** + * Sets electricity_allocation + * + * @param float $electricity_allocation Percentage of electricity use to allocate to this crop, from 0 to 1 + * + * @return self + */ + public function setElectricityAllocation($electricity_allocation) + { + if (is_null($electricity_allocation)) { + throw new \InvalidArgumentException('non-nullable electricity_allocation cannot be null'); + } + $this->container['electricity_allocation'] = $electricity_allocation; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets diesel_use + * + * @return float + */ + public function getDieselUse() + { + return $this->container['diesel_use']; + } + + /** + * Sets diesel_use + * + * @param float $diesel_use Diesel usage in L (litres) + * + * @return self + */ + public function setDieselUse($diesel_use) + { + if (is_null($diesel_use)) { + throw new \InvalidArgumentException('non-nullable diesel_use cannot be null'); + } + $this->container['diesel_use'] = $diesel_use; + + return $this; + } + + /** + * Gets petrol_use + * + * @return float + */ + public function getPetrolUse() + { + return $this->container['petrol_use']; + } + + /** + * Sets petrol_use + * + * @param float $petrol_use Petrol usage in L (litres) + * + * @return self + */ + public function setPetrolUse($petrol_use) + { + if (is_null($petrol_use)) { + throw new \InvalidArgumentException('non-nullable petrol_use cannot be null'); + } + $this->container['petrol_use'] = $petrol_use; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200Response.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200Response.php new file mode 100644 index 00000000..0aaed1fc --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200Response.php @@ -0,0 +1,636 @@ + + */ +class PostVineyard200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostVineyard200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostVineyard200ResponseScope3', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostVineyard200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities[] $intensities Emissions intensity for each vineyard (in order), in t-CO2e/t yield + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInner.php new file mode 100644 index 00000000..b9a0dc92 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostVineyard200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostVineyard200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostVineyard200ResponseScope3', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostVineyard200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..17a2229a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostVineyard200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vineyards_excluding_sequestration' => 'float', + 'vineyards_including_sequestration' => 'float', + 'crop_produced_kg' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vineyards_excluding_sequestration' => null, + 'vineyards_including_sequestration' => null, + 'crop_produced_kg' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vineyards_excluding_sequestration' => false, + 'vineyards_including_sequestration' => false, + 'crop_produced_kg' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vineyards_excluding_sequestration' => 'vineyardsExcludingSequestration', + 'vineyards_including_sequestration' => 'vineyardsIncludingSequestration', + 'crop_produced_kg' => 'cropProducedKg' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vineyards_excluding_sequestration' => 'setVineyardsExcludingSequestration', + 'vineyards_including_sequestration' => 'setVineyardsIncludingSequestration', + 'crop_produced_kg' => 'setCropProducedKg' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vineyards_excluding_sequestration' => 'getVineyardsExcludingSequestration', + 'vineyards_including_sequestration' => 'getVineyardsIncludingSequestration', + 'crop_produced_kg' => 'getCropProducedKg' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vineyards_excluding_sequestration', $data ?? [], null); + $this->setIfExists('vineyards_including_sequestration', $data ?? [], null); + $this->setIfExists('crop_produced_kg', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vineyards_excluding_sequestration'] === null) { + $invalidProperties[] = "'vineyards_excluding_sequestration' can't be null"; + } + if ($this->container['vineyards_including_sequestration'] === null) { + $invalidProperties[] = "'vineyards_including_sequestration' can't be null"; + } + if ($this->container['crop_produced_kg'] === null) { + $invalidProperties[] = "'crop_produced_kg' 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 vineyards_excluding_sequestration + * + * @return float + */ + public function getVineyardsExcludingSequestration() + { + return $this->container['vineyards_excluding_sequestration']; + } + + /** + * Sets vineyards_excluding_sequestration + * + * @param float $vineyards_excluding_sequestration Vineyard emissions intensity excluding sequestration, in kg-CO2e/kg crop + * + * @return self + */ + public function setVineyardsExcludingSequestration($vineyards_excluding_sequestration) + { + if (is_null($vineyards_excluding_sequestration)) { + throw new \InvalidArgumentException('non-nullable vineyards_excluding_sequestration cannot be null'); + } + $this->container['vineyards_excluding_sequestration'] = $vineyards_excluding_sequestration; + + return $this; + } + + /** + * Gets vineyards_including_sequestration + * + * @return float + */ + public function getVineyardsIncludingSequestration() + { + return $this->container['vineyards_including_sequestration']; + } + + /** + * Sets vineyards_including_sequestration + * + * @param float $vineyards_including_sequestration Vineyard emissions intensity including sequestration, in kg-CO2e/kg crop + * + * @return self + */ + public function setVineyardsIncludingSequestration($vineyards_including_sequestration) + { + if (is_null($vineyards_including_sequestration)) { + throw new \InvalidArgumentException('non-nullable vineyards_including_sequestration cannot be null'); + } + $this->container['vineyards_including_sequestration'] = $vineyards_including_sequestration; + + return $this; + } + + /** + * Gets crop_produced_kg + * + * @return float + */ + public function getCropProducedKg() + { + return $this->container['crop_produced_kg']; + } + + /** + * Sets crop_produced_kg + * + * @param float $crop_produced_kg Vineyard crop produced in kg + * + * @return self + */ + public function setCropProducedKg($crop_produced_kg) + { + if (is_null($crop_produced_kg)) { + throw new \InvalidArgumentException('non-nullable crop_produced_kg cannot be null'); + } + $this->container['crop_produced_kg'] = $crop_produced_kg; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseNet.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseNet.php new file mode 100644 index 00000000..cb965294 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseNet.php @@ -0,0 +1,451 @@ + + */ +class PostVineyard200ResponseNet implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response_net'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'float', + 'vineyards' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => null, + 'vineyards' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'vineyards' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'vineyards' => 'vineyards' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'vineyards' => 'setVineyards' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'vineyards' => 'getVineyards' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('vineyards', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if ($this->container['vineyards'] === null) { + $invalidProperties[] = "'vineyards' 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 total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total 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 vineyards + * + * @return float[] + */ + public function getVineyards() + { + return $this->container['vineyards']; + } + + /** + * Sets vineyards + * + * @param float[] $vineyards vineyards + * + * @return self + */ + public function setVineyards($vineyards) + { + if (is_null($vineyards)) { + throw new \InvalidArgumentException('non-nullable vineyards cannot be null'); + } + $this->container['vineyards'] = $vineyards; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope1.php new file mode 100644 index 00000000..f3945710 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope1.php @@ -0,0 +1,932 @@ + + */ +class PostVineyard200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'lime_co2' => 'float', + 'urea_co2' => 'float', + 'waste_water_co2' => 'float', + 'composted_solid_waste_co2' => 'float', + 'fuel_ch4' => 'float', + 'fertiliser_n2_o' => 'float', + 'atmospheric_deposition_n2_o' => 'float', + 'crop_residue_n2_o' => 'float', + 'leaching_and_runoff_n2_o' => 'float', + 'fuel_n2_o' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'lime_co2' => null, + 'urea_co2' => null, + 'waste_water_co2' => null, + 'composted_solid_waste_co2' => null, + 'fuel_ch4' => null, + 'fertiliser_n2_o' => null, + 'atmospheric_deposition_n2_o' => null, + 'crop_residue_n2_o' => null, + 'leaching_and_runoff_n2_o' => null, + 'fuel_n2_o' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'lime_co2' => false, + 'urea_co2' => false, + 'waste_water_co2' => false, + 'composted_solid_waste_co2' => false, + 'fuel_ch4' => false, + 'fertiliser_n2_o' => false, + 'atmospheric_deposition_n2_o' => false, + 'crop_residue_n2_o' => false, + 'leaching_and_runoff_n2_o' => false, + 'fuel_n2_o' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'lime_co2' => 'limeCO2', + 'urea_co2' => 'ureaCO2', + 'waste_water_co2' => 'wasteWaterCO2', + 'composted_solid_waste_co2' => 'compostedSolidWasteCO2', + 'fuel_ch4' => 'fuelCH4', + 'fertiliser_n2_o' => 'fertiliserN2O', + 'atmospheric_deposition_n2_o' => 'atmosphericDepositionN2O', + 'crop_residue_n2_o' => 'cropResidueN2O', + 'leaching_and_runoff_n2_o' => 'leachingAndRunoffN2O', + 'fuel_n2_o' => 'fuelN2O', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'lime_co2' => 'setLimeCo2', + 'urea_co2' => 'setUreaCo2', + 'waste_water_co2' => 'setWasteWaterCo2', + 'composted_solid_waste_co2' => 'setCompostedSolidWasteCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fertiliser_n2_o' => 'setFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'setAtmosphericDepositionN2O', + 'crop_residue_n2_o' => 'setCropResidueN2O', + 'leaching_and_runoff_n2_o' => 'setLeachingAndRunoffN2O', + 'fuel_n2_o' => 'setFuelN2O', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'lime_co2' => 'getLimeCo2', + 'urea_co2' => 'getUreaCo2', + 'waste_water_co2' => 'getWasteWaterCo2', + 'composted_solid_waste_co2' => 'getCompostedSolidWasteCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fertiliser_n2_o' => 'getFertiliserN2O', + 'atmospheric_deposition_n2_o' => 'getAtmosphericDepositionN2O', + 'crop_residue_n2_o' => 'getCropResidueN2O', + 'leaching_and_runoff_n2_o' => 'getLeachingAndRunoffN2O', + 'fuel_n2_o' => 'getFuelN2O', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('lime_co2', $data ?? [], null); + $this->setIfExists('urea_co2', $data ?? [], null); + $this->setIfExists('waste_water_co2', $data ?? [], null); + $this->setIfExists('composted_solid_waste_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fertiliser_n2_o', $data ?? [], null); + $this->setIfExists('atmospheric_deposition_n2_o', $data ?? [], null); + $this->setIfExists('crop_residue_n2_o', $data ?? [], null); + $this->setIfExists('leaching_and_runoff_n2_o', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['lime_co2'] === null) { + $invalidProperties[] = "'lime_co2' can't be null"; + } + if ($this->container['urea_co2'] === null) { + $invalidProperties[] = "'urea_co2' can't be null"; + } + if ($this->container['waste_water_co2'] === null) { + $invalidProperties[] = "'waste_water_co2' can't be null"; + } + if ($this->container['composted_solid_waste_co2'] === null) { + $invalidProperties[] = "'composted_solid_waste_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fertiliser_n2_o'] === null) { + $invalidProperties[] = "'fertiliser_n2_o' can't be null"; + } + if ($this->container['atmospheric_deposition_n2_o'] === null) { + $invalidProperties[] = "'atmospheric_deposition_n2_o' can't be null"; + } + if ($this->container['crop_residue_n2_o'] === null) { + $invalidProperties[] = "'crop_residue_n2_o' can't be null"; + } + if ($this->container['leaching_and_runoff_n2_o'] === null) { + $invalidProperties[] = "'leaching_and_runoff_n2_o' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets lime_co2 + * + * @return float + */ + public function getLimeCo2() + { + return $this->container['lime_co2']; + } + + /** + * Sets lime_co2 + * + * @param float $lime_co2 CO2 emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLimeCo2($lime_co2) + { + if (is_null($lime_co2)) { + throw new \InvalidArgumentException('non-nullable lime_co2 cannot be null'); + } + $this->container['lime_co2'] = $lime_co2; + + return $this; + } + + /** + * Gets urea_co2 + * + * @return float + */ + public function getUreaCo2() + { + return $this->container['urea_co2']; + } + + /** + * Sets urea_co2 + * + * @param float $urea_co2 CO2 emissions from urea, in tonnes-CO2e + * + * @return self + */ + public function setUreaCo2($urea_co2) + { + if (is_null($urea_co2)) { + throw new \InvalidArgumentException('non-nullable urea_co2 cannot be null'); + } + $this->container['urea_co2'] = $urea_co2; + + return $this; + } + + /** + * Gets waste_water_co2 + * + * @return float + */ + public function getWasteWaterCo2() + { + return $this->container['waste_water_co2']; + } + + /** + * Sets waste_water_co2 + * + * @param float $waste_water_co2 Emissions from wastewater, in tonnes-CO2e + * + * @return self + */ + public function setWasteWaterCo2($waste_water_co2) + { + if (is_null($waste_water_co2)) { + throw new \InvalidArgumentException('non-nullable waste_water_co2 cannot be null'); + } + $this->container['waste_water_co2'] = $waste_water_co2; + + return $this; + } + + /** + * Gets composted_solid_waste_co2 + * + * @return float + */ + public function getCompostedSolidWasteCo2() + { + return $this->container['composted_solid_waste_co2']; + } + + /** + * Sets composted_solid_waste_co2 + * + * @param float $composted_solid_waste_co2 Emissions from composted solid waste, in tonnes-CO2e + * + * @return self + */ + public function setCompostedSolidWasteCo2($composted_solid_waste_co2) + { + if (is_null($composted_solid_waste_co2)) { + throw new \InvalidArgumentException('non-nullable composted_solid_waste_co2 cannot be null'); + } + $this->container['composted_solid_waste_co2'] = $composted_solid_waste_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fertiliser_n2_o + * + * @return float + */ + public function getFertiliserN2O() + { + return $this->container['fertiliser_n2_o']; + } + + /** + * Sets fertiliser_n2_o + * + * @param float $fertiliser_n2_o N2O emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliserN2O($fertiliser_n2_o) + { + if (is_null($fertiliser_n2_o)) { + throw new \InvalidArgumentException('non-nullable fertiliser_n2_o cannot be null'); + } + $this->container['fertiliser_n2_o'] = $fertiliser_n2_o; + + return $this; + } + + /** + * Gets atmospheric_deposition_n2_o + * + * @return float + */ + public function getAtmosphericDepositionN2O() + { + return $this->container['atmospheric_deposition_n2_o']; + } + + /** + * Sets atmospheric_deposition_n2_o + * + * @param float $atmospheric_deposition_n2_o N2O emissions from atmospheric deposition, in tonnes-CO2e + * + * @return self + */ + public function setAtmosphericDepositionN2O($atmospheric_deposition_n2_o) + { + if (is_null($atmospheric_deposition_n2_o)) { + throw new \InvalidArgumentException('non-nullable atmospheric_deposition_n2_o cannot be null'); + } + $this->container['atmospheric_deposition_n2_o'] = $atmospheric_deposition_n2_o; + + return $this; + } + + /** + * Gets crop_residue_n2_o + * + * @return float + */ + public function getCropResidueN2O() + { + return $this->container['crop_residue_n2_o']; + } + + /** + * Sets crop_residue_n2_o + * + * @param float $crop_residue_n2_o N2O emissions from crop residue, in tonnes-CO2e + * + * @return self + */ + public function setCropResidueN2O($crop_residue_n2_o) + { + if (is_null($crop_residue_n2_o)) { + throw new \InvalidArgumentException('non-nullable crop_residue_n2_o cannot be null'); + } + $this->container['crop_residue_n2_o'] = $crop_residue_n2_o; + + return $this; + } + + /** + * Gets leaching_and_runoff_n2_o + * + * @return float + */ + public function getLeachingAndRunoffN2O() + { + return $this->container['leaching_and_runoff_n2_o']; + } + + /** + * Sets leaching_and_runoff_n2_o + * + * @param float $leaching_and_runoff_n2_o N2O emissions from leeching and runoff, in tonnes-CO2e + * + * @return self + */ + public function setLeachingAndRunoffN2O($leaching_and_runoff_n2_o) + { + if (is_null($leaching_and_runoff_n2_o)) { + throw new \InvalidArgumentException('non-nullable leaching_and_runoff_n2_o cannot be null'); + } + $this->container['leaching_and_runoff_n2_o'] = $leaching_and_runoff_n2_o; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope3.php new file mode 100644 index 00000000..8a40cca5 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyard200ResponseScope3.php @@ -0,0 +1,747 @@ + + */ +class PostVineyard200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fertiliser' => 'float', + 'herbicide' => 'float', + 'electricity' => 'float', + 'fuel' => 'float', + 'lime' => 'float', + 'commercial_flights' => 'float', + 'inbound_freight' => 'float', + 'solid_waste_sent_offsite' => 'float', + 'outbound_freight' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fertiliser' => null, + 'herbicide' => null, + 'electricity' => null, + 'fuel' => null, + 'lime' => null, + 'commercial_flights' => null, + 'inbound_freight' => null, + 'solid_waste_sent_offsite' => null, + 'outbound_freight' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fertiliser' => false, + 'herbicide' => false, + 'electricity' => false, + 'fuel' => false, + 'lime' => false, + 'commercial_flights' => false, + 'inbound_freight' => false, + 'solid_waste_sent_offsite' => false, + 'outbound_freight' => 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 = [ + 'fertiliser' => 'fertiliser', + 'herbicide' => 'herbicide', + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'lime' => 'lime', + 'commercial_flights' => 'commercialFlights', + 'inbound_freight' => 'inboundFreight', + 'solid_waste_sent_offsite' => 'solidWasteSentOffsite', + 'outbound_freight' => 'outboundFreight', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fertiliser' => 'setFertiliser', + 'herbicide' => 'setHerbicide', + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'lime' => 'setLime', + 'commercial_flights' => 'setCommercialFlights', + 'inbound_freight' => 'setInboundFreight', + 'solid_waste_sent_offsite' => 'setSolidWasteSentOffsite', + 'outbound_freight' => 'setOutboundFreight', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fertiliser' => 'getFertiliser', + 'herbicide' => 'getHerbicide', + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'lime' => 'getLime', + 'commercial_flights' => 'getCommercialFlights', + 'inbound_freight' => 'getInboundFreight', + 'solid_waste_sent_offsite' => 'getSolidWasteSentOffsite', + 'outbound_freight' => 'getOutboundFreight', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fertiliser', $data ?? [], null); + $this->setIfExists('herbicide', $data ?? [], null); + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('lime', $data ?? [], null); + $this->setIfExists('commercial_flights', $data ?? [], null); + $this->setIfExists('inbound_freight', $data ?? [], null); + $this->setIfExists('solid_waste_sent_offsite', $data ?? [], null); + $this->setIfExists('outbound_freight', $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['fertiliser'] === null) { + $invalidProperties[] = "'fertiliser' can't be null"; + } + if ($this->container['herbicide'] === null) { + $invalidProperties[] = "'herbicide' can't be null"; + } + if ($this->container['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['lime'] === null) { + $invalidProperties[] = "'lime' can't be null"; + } + if ($this->container['commercial_flights'] === null) { + $invalidProperties[] = "'commercial_flights' can't be null"; + } + if ($this->container['inbound_freight'] === null) { + $invalidProperties[] = "'inbound_freight' can't be null"; + } + if ($this->container['solid_waste_sent_offsite'] === null) { + $invalidProperties[] = "'solid_waste_sent_offsite' can't be null"; + } + if ($this->container['outbound_freight'] === null) { + $invalidProperties[] = "'outbound_freight' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fertiliser + * + * @return float + */ + public function getFertiliser() + { + return $this->container['fertiliser']; + } + + /** + * Sets fertiliser + * + * @param float $fertiliser Emissions from fertiliser, in tonnes-CO2e + * + * @return self + */ + public function setFertiliser($fertiliser) + { + if (is_null($fertiliser)) { + throw new \InvalidArgumentException('non-nullable fertiliser cannot be null'); + } + $this->container['fertiliser'] = $fertiliser; + + return $this; + } + + /** + * Gets herbicide + * + * @return float + */ + public function getHerbicide() + { + return $this->container['herbicide']; + } + + /** + * Sets herbicide + * + * @param float $herbicide Emissions from herbicide, in tonnes-CO2e + * + * @return self + */ + public function setHerbicide($herbicide) + { + if (is_null($herbicide)) { + throw new \InvalidArgumentException('non-nullable herbicide cannot be null'); + } + $this->container['herbicide'] = $herbicide; + + return $this; + } + + /** + * Gets electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets lime + * + * @return float + */ + public function getLime() + { + return $this->container['lime']; + } + + /** + * Sets lime + * + * @param float $lime Emissions from lime, in tonnes-CO2e + * + * @return self + */ + public function setLime($lime) + { + if (is_null($lime)) { + throw new \InvalidArgumentException('non-nullable lime cannot be null'); + } + $this->container['lime'] = $lime; + + return $this; + } + + /** + * Gets commercial_flights + * + * @return float + */ + public function getCommercialFlights() + { + return $this->container['commercial_flights']; + } + + /** + * Sets commercial_flights + * + * @param float $commercial_flights Emissions from commercial flights, in tonnes-CO2e + * + * @return self + */ + public function setCommercialFlights($commercial_flights) + { + if (is_null($commercial_flights)) { + throw new \InvalidArgumentException('non-nullable commercial_flights cannot be null'); + } + $this->container['commercial_flights'] = $commercial_flights; + + return $this; + } + + /** + * Gets inbound_freight + * + * @return float + */ + public function getInboundFreight() + { + return $this->container['inbound_freight']; + } + + /** + * Sets inbound_freight + * + * @param float $inbound_freight Emissions from inbound freight, in tonnes-CO2e + * + * @return self + */ + public function setInboundFreight($inbound_freight) + { + if (is_null($inbound_freight)) { + throw new \InvalidArgumentException('non-nullable inbound_freight cannot be null'); + } + $this->container['inbound_freight'] = $inbound_freight; + + return $this; + } + + /** + * Gets solid_waste_sent_offsite + * + * @return float + */ + public function getSolidWasteSentOffsite() + { + return $this->container['solid_waste_sent_offsite']; + } + + /** + * Sets solid_waste_sent_offsite + * + * @param float $solid_waste_sent_offsite Emissions from solid waste sent offsite, in tonnes-CO2e + * + * @return self + */ + public function setSolidWasteSentOffsite($solid_waste_sent_offsite) + { + if (is_null($solid_waste_sent_offsite)) { + throw new \InvalidArgumentException('non-nullable solid_waste_sent_offsite cannot be null'); + } + $this->container['solid_waste_sent_offsite'] = $solid_waste_sent_offsite; + + return $this; + } + + /** + * Gets outbound_freight + * + * @return float + */ + public function getOutboundFreight() + { + return $this->container['outbound_freight']; + } + + /** + * Sets outbound_freight + * + * @param float $outbound_freight Emissions from outbound freight, in tonnes-CO2e + * + * @return self + */ + public function setOutboundFreight($outbound_freight) + { + if (is_null($outbound_freight)) { + throw new \InvalidArgumentException('non-nullable outbound_freight cannot be null'); + } + $this->container['outbound_freight'] = $outbound_freight; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyardRequest.php b/examples/php-api-client/api-client/lib/Model/PostVineyardRequest.php new file mode 100644 index 00000000..8e418210 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyardRequest.php @@ -0,0 +1,451 @@ + + */ +class PostVineyardRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vineyards' => '\OpenAPI\Client\Model\PostVineyardRequestVineyardsInner[]', + 'vegetation' => '\OpenAPI\Client\Model\PostVineyardRequestVegetationInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vineyards' => null, + 'vegetation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vineyards' => false, + 'vegetation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vineyards' => 'vineyards', + 'vegetation' => 'vegetation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vineyards' => 'setVineyards', + 'vegetation' => 'setVegetation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vineyards' => 'getVineyards', + 'vegetation' => 'getVegetation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vineyards', $data ?? [], null); + $this->setIfExists('vegetation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vineyards'] === null) { + $invalidProperties[] = "'vineyards' can't be null"; + } + if ($this->container['vegetation'] === null) { + $invalidProperties[] = "'vegetation' 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 vineyards + * + * @return \OpenAPI\Client\Model\PostVineyardRequestVineyardsInner[] + */ + public function getVineyards() + { + return $this->container['vineyards']; + } + + /** + * Sets vineyards + * + * @param \OpenAPI\Client\Model\PostVineyardRequestVineyardsInner[] $vineyards vineyards + * + * @return self + */ + public function setVineyards($vineyards) + { + if (is_null($vineyards)) { + throw new \InvalidArgumentException('non-nullable vineyards cannot be null'); + } + $this->container['vineyards'] = $vineyards; + + return $this; + } + + /** + * Gets vegetation + * + * @return \OpenAPI\Client\Model\PostVineyardRequestVegetationInner[] + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostVineyardRequestVegetationInner[] $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVegetationInner.php b/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVegetationInner.php new file mode 100644 index 00000000..f2a85fb2 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVegetationInner.php @@ -0,0 +1,450 @@ + + */ +class PostVineyardRequestVegetationInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_request_vegetation_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'vegetation' => '\OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation', + 'allocation_to_vineyards' => 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'vegetation' => null, + 'allocation_to_vineyards' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'vegetation' => false, + 'allocation_to_vineyards' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'vegetation' => 'vegetation', + 'allocation_to_vineyards' => 'allocationToVineyards' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'vegetation' => 'setVegetation', + 'allocation_to_vineyards' => 'setAllocationToVineyards' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'vegetation' => 'getVegetation', + 'allocation_to_vineyards' => 'getAllocationToVineyards' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('vegetation', $data ?? [], null); + $this->setIfExists('allocation_to_vineyards', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['vegetation'] === null) { + $invalidProperties[] = "'vegetation' can't be null"; + } + if ($this->container['allocation_to_vineyards'] === null) { + $invalidProperties[] = "'allocation_to_vineyards' 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 vegetation + * + * @return \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation + */ + public function getVegetation() + { + return $this->container['vegetation']; + } + + /** + * Sets vegetation + * + * @param \OpenAPI\Client\Model\PostBeefRequestVegetationInnerVegetation $vegetation vegetation + * + * @return self + */ + public function setVegetation($vegetation) + { + if (is_null($vegetation)) { + throw new \InvalidArgumentException('non-nullable vegetation cannot be null'); + } + $this->container['vegetation'] = $vegetation; + + return $this; + } + + /** + * Gets allocation_to_vineyards + * + * @return float[] + */ + public function getAllocationToVineyards() + { + return $this->container['allocation_to_vineyards']; + } + + /** + * Sets allocation_to_vineyards + * + * @param float[] $allocation_to_vineyards allocation_to_vineyards + * + * @return self + */ + public function setAllocationToVineyards($allocation_to_vineyards) + { + if (is_null($allocation_to_vineyards)) { + throw new \InvalidArgumentException('non-nullable allocation_to_vineyards cannot be null'); + } + $this->container['allocation_to_vineyards'] = $allocation_to_vineyards; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVineyardsInner.php b/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVineyardsInner.php new file mode 100644 index 00000000..d1ccb685 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostVineyardRequestVineyardsInner.php @@ -0,0 +1,1396 @@ + + */ +class PostVineyardRequestVineyardsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_vineyard_request_vineyards_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'rainfall_above600' => 'bool', + 'irrigated' => 'bool', + 'area_planted' => 'float', + 'average_yield' => 'float', + 'non_urea_nitrogen' => 'float', + 'phosphorus_application' => 'float', + 'potassium_application' => 'float', + 'sulfur_application' => 'float', + 'urea_application' => 'float', + 'urea_ammonium_nitrate' => 'float', + 'limestone' => 'float', + 'limestone_fraction' => 'float', + 'herbicide_use' => 'float', + 'glyphosate_other_herbicide_use' => 'float', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'electricity_source' => 'string', + 'fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel', + 'fluid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[]', + 'solid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste', + 'inbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'outbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'total_commercial_flights_km' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'rainfall_above600' => null, + 'irrigated' => null, + 'area_planted' => null, + 'average_yield' => null, + 'non_urea_nitrogen' => null, + 'phosphorus_application' => null, + 'potassium_application' => null, + 'sulfur_application' => null, + 'urea_application' => null, + 'urea_ammonium_nitrate' => null, + 'limestone' => null, + 'limestone_fraction' => null, + 'herbicide_use' => null, + 'glyphosate_other_herbicide_use' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'electricity_source' => null, + 'fuel' => null, + 'fluid_waste' => null, + 'solid_waste' => null, + 'inbound_freight' => null, + 'outbound_freight' => null, + 'total_commercial_flights_km' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'rainfall_above600' => false, + 'irrigated' => false, + 'area_planted' => false, + 'average_yield' => false, + 'non_urea_nitrogen' => false, + 'phosphorus_application' => false, + 'potassium_application' => false, + 'sulfur_application' => false, + 'urea_application' => false, + 'urea_ammonium_nitrate' => false, + 'limestone' => false, + 'limestone_fraction' => false, + 'herbicide_use' => false, + 'glyphosate_other_herbicide_use' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'electricity_source' => false, + 'fuel' => false, + 'fluid_waste' => false, + 'solid_waste' => false, + 'inbound_freight' => false, + 'outbound_freight' => false, + 'total_commercial_flights_km' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'rainfall_above600' => 'rainfallAbove600', + 'irrigated' => 'irrigated', + 'area_planted' => 'areaPlanted', + 'average_yield' => 'averageYield', + 'non_urea_nitrogen' => 'nonUreaNitrogen', + 'phosphorus_application' => 'phosphorusApplication', + 'potassium_application' => 'potassiumApplication', + 'sulfur_application' => 'sulfurApplication', + 'urea_application' => 'ureaApplication', + 'urea_ammonium_nitrate' => 'ureaAmmoniumNitrate', + 'limestone' => 'limestone', + 'limestone_fraction' => 'limestoneFraction', + 'herbicide_use' => 'herbicideUse', + 'glyphosate_other_herbicide_use' => 'glyphosateOtherHerbicideUse', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'electricity_source' => 'electricitySource', + 'fuel' => 'fuel', + 'fluid_waste' => 'fluidWaste', + 'solid_waste' => 'solidWaste', + 'inbound_freight' => 'inboundFreight', + 'outbound_freight' => 'outboundFreight', + 'total_commercial_flights_km' => 'totalCommercialFlightsKm' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'rainfall_above600' => 'setRainfallAbove600', + 'irrigated' => 'setIrrigated', + 'area_planted' => 'setAreaPlanted', + 'average_yield' => 'setAverageYield', + 'non_urea_nitrogen' => 'setNonUreaNitrogen', + 'phosphorus_application' => 'setPhosphorusApplication', + 'potassium_application' => 'setPotassiumApplication', + 'sulfur_application' => 'setSulfurApplication', + 'urea_application' => 'setUreaApplication', + 'urea_ammonium_nitrate' => 'setUreaAmmoniumNitrate', + 'limestone' => 'setLimestone', + 'limestone_fraction' => 'setLimestoneFraction', + 'herbicide_use' => 'setHerbicideUse', + 'glyphosate_other_herbicide_use' => 'setGlyphosateOtherHerbicideUse', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'electricity_source' => 'setElectricitySource', + 'fuel' => 'setFuel', + 'fluid_waste' => 'setFluidWaste', + 'solid_waste' => 'setSolidWaste', + 'inbound_freight' => 'setInboundFreight', + 'outbound_freight' => 'setOutboundFreight', + 'total_commercial_flights_km' => 'setTotalCommercialFlightsKm' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'rainfall_above600' => 'getRainfallAbove600', + 'irrigated' => 'getIrrigated', + 'area_planted' => 'getAreaPlanted', + 'average_yield' => 'getAverageYield', + 'non_urea_nitrogen' => 'getNonUreaNitrogen', + 'phosphorus_application' => 'getPhosphorusApplication', + 'potassium_application' => 'getPotassiumApplication', + 'sulfur_application' => 'getSulfurApplication', + 'urea_application' => 'getUreaApplication', + 'urea_ammonium_nitrate' => 'getUreaAmmoniumNitrate', + 'limestone' => 'getLimestone', + 'limestone_fraction' => 'getLimestoneFraction', + 'herbicide_use' => 'getHerbicideUse', + 'glyphosate_other_herbicide_use' => 'getGlyphosateOtherHerbicideUse', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'electricity_source' => 'getElectricitySource', + 'fuel' => 'getFuel', + 'fluid_waste' => 'getFluidWaste', + 'solid_waste' => 'getSolidWaste', + 'inbound_freight' => 'getInboundFreight', + 'outbound_freight' => 'getOutboundFreight', + 'total_commercial_flights_km' => 'getTotalCommercialFlightsKm' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('rainfall_above600', $data ?? [], null); + $this->setIfExists('irrigated', $data ?? [], null); + $this->setIfExists('area_planted', $data ?? [], null); + $this->setIfExists('average_yield', $data ?? [], null); + $this->setIfExists('non_urea_nitrogen', $data ?? [], null); + $this->setIfExists('phosphorus_application', $data ?? [], null); + $this->setIfExists('potassium_application', $data ?? [], null); + $this->setIfExists('sulfur_application', $data ?? [], null); + $this->setIfExists('urea_application', $data ?? [], null); + $this->setIfExists('urea_ammonium_nitrate', $data ?? [], null); + $this->setIfExists('limestone', $data ?? [], null); + $this->setIfExists('limestone_fraction', $data ?? [], null); + $this->setIfExists('herbicide_use', $data ?? [], null); + $this->setIfExists('glyphosate_other_herbicide_use', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('fluid_waste', $data ?? [], null); + $this->setIfExists('solid_waste', $data ?? [], null); + $this->setIfExists('inbound_freight', $data ?? [], null); + $this->setIfExists('outbound_freight', $data ?? [], null); + $this->setIfExists('total_commercial_flights_km', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['rainfall_above600'] === null) { + $invalidProperties[] = "'rainfall_above600' can't be null"; + } + if ($this->container['irrigated'] === null) { + $invalidProperties[] = "'irrigated' can't be null"; + } + if ($this->container['area_planted'] === null) { + $invalidProperties[] = "'area_planted' can't be null"; + } + if ($this->container['average_yield'] === null) { + $invalidProperties[] = "'average_yield' can't be null"; + } + if ($this->container['non_urea_nitrogen'] === null) { + $invalidProperties[] = "'non_urea_nitrogen' can't be null"; + } + if ($this->container['phosphorus_application'] === null) { + $invalidProperties[] = "'phosphorus_application' can't be null"; + } + if ($this->container['potassium_application'] === null) { + $invalidProperties[] = "'potassium_application' can't be null"; + } + if ($this->container['sulfur_application'] === null) { + $invalidProperties[] = "'sulfur_application' can't be null"; + } + if ($this->container['urea_application'] === null) { + $invalidProperties[] = "'urea_application' can't be null"; + } + if ($this->container['urea_ammonium_nitrate'] === null) { + $invalidProperties[] = "'urea_ammonium_nitrate' can't be null"; + } + if ($this->container['limestone'] === null) { + $invalidProperties[] = "'limestone' can't be null"; + } + if ($this->container['limestone_fraction'] === null) { + $invalidProperties[] = "'limestone_fraction' can't be null"; + } + if ($this->container['herbicide_use'] === null) { + $invalidProperties[] = "'herbicide_use' can't be null"; + } + if ($this->container['glyphosate_other_herbicide_use'] === null) { + $invalidProperties[] = "'glyphosate_other_herbicide_use' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['fluid_waste'] === null) { + $invalidProperties[] = "'fluid_waste' can't be null"; + } + if ($this->container['solid_waste'] === null) { + $invalidProperties[] = "'solid_waste' can't be null"; + } + if ($this->container['inbound_freight'] === null) { + $invalidProperties[] = "'inbound_freight' can't be null"; + } + if ($this->container['outbound_freight'] === null) { + $invalidProperties[] = "'outbound_freight' can't be null"; + } + if ($this->container['total_commercial_flights_km'] === null) { + $invalidProperties[] = "'total_commercial_flights_km' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets rainfall_above600 + * + * @return bool + */ + public function getRainfallAbove600() + { + return $this->container['rainfall_above600']; + } + + /** + * Sets rainfall_above600 + * + * @param bool $rainfall_above600 Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm + * + * @return self + */ + public function setRainfallAbove600($rainfall_above600) + { + if (is_null($rainfall_above600)) { + throw new \InvalidArgumentException('non-nullable rainfall_above600 cannot be null'); + } + $this->container['rainfall_above600'] = $rainfall_above600; + + return $this; + } + + /** + * Gets irrigated + * + * @return bool + */ + public function getIrrigated() + { + return $this->container['irrigated']; + } + + /** + * Sets irrigated + * + * @param bool $irrigated Is the crop irrigated? + * + * @return self + */ + public function setIrrigated($irrigated) + { + if (is_null($irrigated)) { + throw new \InvalidArgumentException('non-nullable irrigated cannot be null'); + } + $this->container['irrigated'] = $irrigated; + + return $this; + } + + /** + * Gets area_planted + * + * @return float + */ + public function getAreaPlanted() + { + return $this->container['area_planted']; + } + + /** + * Sets area_planted + * + * @param float $area_planted Area planted, in ha (hectares) + * + * @return self + */ + public function setAreaPlanted($area_planted) + { + if (is_null($area_planted)) { + throw new \InvalidArgumentException('non-nullable area_planted cannot be null'); + } + $this->container['area_planted'] = $area_planted; + + return $this; + } + + /** + * Gets average_yield + * + * @return float + */ + public function getAverageYield() + { + return $this->container['average_yield']; + } + + /** + * Sets average_yield + * + * @param float $average_yield Average yield, in t/ha (tonnes per hectare) + * + * @return self + */ + public function setAverageYield($average_yield) + { + if (is_null($average_yield)) { + throw new \InvalidArgumentException('non-nullable average_yield cannot be null'); + } + $this->container['average_yield'] = $average_yield; + + return $this; + } + + /** + * Gets non_urea_nitrogen + * + * @return float + */ + public function getNonUreaNitrogen() + { + return $this->container['non_urea_nitrogen']; + } + + /** + * Sets non_urea_nitrogen + * + * @param float $non_urea_nitrogen Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare) + * + * @return self + */ + public function setNonUreaNitrogen($non_urea_nitrogen) + { + if (is_null($non_urea_nitrogen)) { + throw new \InvalidArgumentException('non-nullable non_urea_nitrogen cannot be null'); + } + $this->container['non_urea_nitrogen'] = $non_urea_nitrogen; + + return $this; + } + + /** + * Gets phosphorus_application + * + * @return float + */ + public function getPhosphorusApplication() + { + return $this->container['phosphorus_application']; + } + + /** + * Sets phosphorus_application + * + * @param float $phosphorus_application Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare) + * + * @return self + */ + public function setPhosphorusApplication($phosphorus_application) + { + if (is_null($phosphorus_application)) { + throw new \InvalidArgumentException('non-nullable phosphorus_application cannot be null'); + } + $this->container['phosphorus_application'] = $phosphorus_application; + + return $this; + } + + /** + * Gets potassium_application + * + * @return float + */ + public function getPotassiumApplication() + { + return $this->container['potassium_application']; + } + + /** + * Sets potassium_application + * + * @param float $potassium_application Potassium application, in kg K/ha (kilograms of potassium per hectare) + * + * @return self + */ + public function setPotassiumApplication($potassium_application) + { + if (is_null($potassium_application)) { + throw new \InvalidArgumentException('non-nullable potassium_application cannot be null'); + } + $this->container['potassium_application'] = $potassium_application; + + return $this; + } + + /** + * Gets sulfur_application + * + * @return float + */ + public function getSulfurApplication() + { + return $this->container['sulfur_application']; + } + + /** + * Sets sulfur_application + * + * @param float $sulfur_application Sulfur application, in kg S/ha (kilograms of sulfur per hectare) + * + * @return self + */ + public function setSulfurApplication($sulfur_application) + { + if (is_null($sulfur_application)) { + throw new \InvalidArgumentException('non-nullable sulfur_application cannot be null'); + } + $this->container['sulfur_application'] = $sulfur_application; + + return $this; + } + + /** + * Gets urea_application + * + * @return float + */ + public function getUreaApplication() + { + return $this->container['urea_application']; + } + + /** + * Sets urea_application + * + * @param float $urea_application Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare) + * + * @return self + */ + public function setUreaApplication($urea_application) + { + if (is_null($urea_application)) { + throw new \InvalidArgumentException('non-nullable urea_application cannot be null'); + } + $this->container['urea_application'] = $urea_application; + + return $this; + } + + /** + * Gets urea_ammonium_nitrate + * + * @return float + */ + public function getUreaAmmoniumNitrate() + { + return $this->container['urea_ammonium_nitrate']; + } + + /** + * Sets urea_ammonium_nitrate + * + * @param float $urea_ammonium_nitrate Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare) + * + * @return self + */ + public function setUreaAmmoniumNitrate($urea_ammonium_nitrate) + { + if (is_null($urea_ammonium_nitrate)) { + throw new \InvalidArgumentException('non-nullable urea_ammonium_nitrate cannot be null'); + } + $this->container['urea_ammonium_nitrate'] = $urea_ammonium_nitrate; + + return $this; + } + + /** + * Gets limestone + * + * @return float + */ + public function getLimestone() + { + return $this->container['limestone']; + } + + /** + * Sets limestone + * + * @param float $limestone Lime applied in tonnes + * + * @return self + */ + public function setLimestone($limestone) + { + if (is_null($limestone)) { + throw new \InvalidArgumentException('non-nullable limestone cannot be null'); + } + $this->container['limestone'] = $limestone; + + return $this; + } + + /** + * Gets limestone_fraction + * + * @return float + */ + public function getLimestoneFraction() + { + return $this->container['limestone_fraction']; + } + + /** + * Sets limestone_fraction + * + * @param float $limestone_fraction Fraction of lime as limestone vs dolomite, between 0 and 1 + * + * @return self + */ + public function setLimestoneFraction($limestone_fraction) + { + if (is_null($limestone_fraction)) { + throw new \InvalidArgumentException('non-nullable limestone_fraction cannot be null'); + } + $this->container['limestone_fraction'] = $limestone_fraction; + + return $this; + } + + /** + * Gets herbicide_use + * + * @return float + */ + public function getHerbicideUse() + { + return $this->container['herbicide_use']; + } + + /** + * Sets herbicide_use + * + * @param float $herbicide_use Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram) + * + * @return self + */ + public function setHerbicideUse($herbicide_use) + { + if (is_null($herbicide_use)) { + throw new \InvalidArgumentException('non-nullable herbicide_use cannot be null'); + } + $this->container['herbicide_use'] = $herbicide_use; + + return $this; + } + + /** + * Gets glyphosate_other_herbicide_use + * + * @return float + */ + public function getGlyphosateOtherHerbicideUse() + { + return $this->container['glyphosate_other_herbicide_use']; + } + + /** + * Sets glyphosate_other_herbicide_use + * + * @param float $glyphosate_other_herbicide_use Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram) + * + * @return self + */ + public function setGlyphosateOtherHerbicideUse($glyphosate_other_herbicide_use) + { + if (is_null($glyphosate_other_herbicide_use)) { + throw new \InvalidArgumentException('non-nullable glyphosate_other_herbicide_use cannot be null'); + } + $this->container['glyphosate_other_herbicide_use'] = $glyphosate_other_herbicide_use; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostVineyardRequestVineyardsInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostVineyardRequestVineyardsInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel $fuel fuel + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets fluid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] + */ + public function getFluidWaste() + { + return $this->container['fluid_waste']; + } + + /** + * Sets fluid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] $fluid_waste Amount of fluid waste, in kL (kilolitres) + * + * @return self + */ + public function setFluidWaste($fluid_waste) + { + if (is_null($fluid_waste)) { + throw new \InvalidArgumentException('non-nullable fluid_waste cannot be null'); + } + $this->container['fluid_waste'] = $fluid_waste; + + return $this; + } + + /** + * Gets solid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste + */ + public function getSolidWaste() + { + return $this->container['solid_waste']; + } + + /** + * Sets solid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste $solid_waste solid_waste + * + * @return self + */ + public function setSolidWaste($solid_waste) + { + if (is_null($solid_waste)) { + throw new \InvalidArgumentException('non-nullable solid_waste cannot be null'); + } + $this->container['solid_waste'] = $solid_waste; + + return $this; + } + + /** + * Gets inbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getInboundFreight() + { + return $this->container['inbound_freight']; + } + + /** + * Sets inbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $inbound_freight Services used to transport goods to the enterprise + * + * @return self + */ + public function setInboundFreight($inbound_freight) + { + if (is_null($inbound_freight)) { + throw new \InvalidArgumentException('non-nullable inbound_freight cannot be null'); + } + $this->container['inbound_freight'] = $inbound_freight; + + return $this; + } + + /** + * Gets outbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getOutboundFreight() + { + return $this->container['outbound_freight']; + } + + /** + * Sets outbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $outbound_freight Services used to transport goods from the enterprise + * + * @return self + */ + public function setOutboundFreight($outbound_freight) + { + if (is_null($outbound_freight)) { + throw new \InvalidArgumentException('non-nullable outbound_freight cannot be null'); + } + $this->container['outbound_freight'] = $outbound_freight; + + return $this; + } + + /** + * Gets total_commercial_flights_km + * + * @return float + */ + public function getTotalCommercialFlightsKm() + { + return $this->container['total_commercial_flights_km']; + } + + /** + * Sets total_commercial_flights_km + * + * @param float $total_commercial_flights_km Total distance of commercial flights, in km (kilometers) + * + * @return self + */ + public function setTotalCommercialFlightsKm($total_commercial_flights_km) + { + if (is_null($total_commercial_flights_km)) { + throw new \InvalidArgumentException('non-nullable total_commercial_flights_km cannot be null'); + } + $this->container['total_commercial_flights_km'] = $total_commercial_flights_km; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200Response.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200Response.php new file mode 100644 index 00000000..203e51ec --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200Response.php @@ -0,0 +1,673 @@ + + */ +class PostWildcatchfishery200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope3', + 'purchased_offsets' => '\OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration', + 'intermediate' => '\OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntermediateInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'purchased_offsets' => null, + 'net' => null, + 'intensities' => null, + 'carbon_sequestration' => null, + 'intermediate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'purchased_offsets' => false, + 'net' => false, + 'intensities' => false, + 'carbon_sequestration' => false, + 'intermediate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'purchased_offsets' => 'purchasedOffsets', + 'net' => 'net', + 'intensities' => 'intensities', + 'carbon_sequestration' => 'carbonSequestration', + 'intermediate' => 'intermediate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'purchased_offsets' => 'setPurchasedOffsets', + 'net' => 'setNet', + 'intensities' => 'setIntensities', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intermediate' => 'setIntermediate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'purchased_offsets' => 'getPurchasedOffsets', + 'net' => 'getNet', + 'intensities' => 'getIntensities', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intermediate' => 'getIntermediate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('purchased_offsets', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['purchased_offsets'] === null) { + $invalidProperties[] = "'purchased_offsets' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets purchased_offsets + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets + */ + public function getPurchasedOffsets() + { + return $this->container['purchased_offsets']; + } + + /** + * Sets purchased_offsets + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets $purchased_offsets purchased_offsets + * + * @return self + */ + public function setPurchasedOffsets($purchased_offsets) + { + if (is_null($purchased_offsets)) { + throw new \InvalidArgumentException('non-nullable purchased_offsets cannot be null'); + } + $this->container['purchased_offsets'] = $purchased_offsets; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntensities.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntensities.php new file mode 100644 index 00000000..266ec80a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostWildcatchfishery200ResponseIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_200_response_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total_harvest_weight_kg' => 'float', + 'wild_catch_fishery_excluding_carbon_offsets' => 'float', + 'wild_catch_fishery_including_carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total_harvest_weight_kg' => null, + 'wild_catch_fishery_excluding_carbon_offsets' => null, + 'wild_catch_fishery_including_carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total_harvest_weight_kg' => false, + 'wild_catch_fishery_excluding_carbon_offsets' => false, + 'wild_catch_fishery_including_carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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_harvest_weight_kg' => 'totalHarvestWeightKg', + 'wild_catch_fishery_excluding_carbon_offsets' => 'wildCatchFisheryExcludingCarbonOffsets', + 'wild_catch_fishery_including_carbon_offsets' => 'wildCatchFisheryIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total_harvest_weight_kg' => 'setTotalHarvestWeightKg', + 'wild_catch_fishery_excluding_carbon_offsets' => 'setWildCatchFisheryExcludingCarbonOffsets', + 'wild_catch_fishery_including_carbon_offsets' => 'setWildCatchFisheryIncludingCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total_harvest_weight_kg' => 'getTotalHarvestWeightKg', + 'wild_catch_fishery_excluding_carbon_offsets' => 'getWildCatchFisheryExcludingCarbonOffsets', + 'wild_catch_fishery_including_carbon_offsets' => 'getWildCatchFisheryIncludingCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('total_harvest_weight_kg', $data ?? [], null); + $this->setIfExists('wild_catch_fishery_excluding_carbon_offsets', $data ?? [], null); + $this->setIfExists('wild_catch_fishery_including_carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['total_harvest_weight_kg'] === null) { + $invalidProperties[] = "'total_harvest_weight_kg' can't be null"; + } + if ($this->container['wild_catch_fishery_excluding_carbon_offsets'] === null) { + $invalidProperties[] = "'wild_catch_fishery_excluding_carbon_offsets' can't be null"; + } + if ($this->container['wild_catch_fishery_including_carbon_offsets'] === null) { + $invalidProperties[] = "'wild_catch_fishery_including_carbon_offsets' 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 total_harvest_weight_kg + * + * @return float + */ + public function getTotalHarvestWeightKg() + { + return $this->container['total_harvest_weight_kg']; + } + + /** + * Sets total_harvest_weight_kg + * + * @param float $total_harvest_weight_kg Total harvest weight in kg + * + * @return self + */ + public function setTotalHarvestWeightKg($total_harvest_weight_kg) + { + if (is_null($total_harvest_weight_kg)) { + throw new \InvalidArgumentException('non-nullable total_harvest_weight_kg cannot be null'); + } + $this->container['total_harvest_weight_kg'] = $total_harvest_weight_kg; + + return $this; + } + + /** + * Gets wild_catch_fishery_excluding_carbon_offsets + * + * @return float + */ + public function getWildCatchFisheryExcludingCarbonOffsets() + { + return $this->container['wild_catch_fishery_excluding_carbon_offsets']; + } + + /** + * Sets wild_catch_fishery_excluding_carbon_offsets + * + * @param float $wild_catch_fishery_excluding_carbon_offsets Wild catch fishery emissions intensity excluding sequestration, in kg-CO2e/kg harvest weight + * + * @return self + */ + public function setWildCatchFisheryExcludingCarbonOffsets($wild_catch_fishery_excluding_carbon_offsets) + { + if (is_null($wild_catch_fishery_excluding_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable wild_catch_fishery_excluding_carbon_offsets cannot be null'); + } + $this->container['wild_catch_fishery_excluding_carbon_offsets'] = $wild_catch_fishery_excluding_carbon_offsets; + + return $this; + } + + /** + * Gets wild_catch_fishery_including_carbon_offsets + * + * @return float + */ + public function getWildCatchFisheryIncludingCarbonOffsets() + { + return $this->container['wild_catch_fishery_including_carbon_offsets']; + } + + /** + * Sets wild_catch_fishery_including_carbon_offsets + * + * @param float $wild_catch_fishery_including_carbon_offsets Wild catch fishery emissions intensity including sequestration, in kg-CO2e/kg harvest weight + * + * @return self + */ + public function setWildCatchFisheryIncludingCarbonOffsets($wild_catch_fishery_including_carbon_offsets) + { + if (is_null($wild_catch_fishery_including_carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable wild_catch_fishery_including_carbon_offsets cannot be null'); + } + $this->container['wild_catch_fishery_including_carbon_offsets'] = $wild_catch_fishery_including_carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntermediateInner.php new file mode 100644 index 00000000..3283b129 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseIntermediateInner.php @@ -0,0 +1,636 @@ + + */ +class PostWildcatchfishery200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope3', + 'intensities' => '\OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'carbon_sequestration' => '\OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'intensities' => null, + 'net' => null, + 'carbon_sequestration' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'intensities' => false, + 'net' => false, + 'carbon_sequestration' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'intensities' => 'intensities', + 'net' => 'net', + 'carbon_sequestration' => 'carbonSequestration' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'intensities' => 'setIntensities', + 'net' => 'setNet', + 'carbon_sequestration' => 'setCarbonSequestration' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'intensities' => 'getIntensities', + 'net' => 'getNet', + 'carbon_sequestration' => 'getCarbonSequestration' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostWildcatchfishery200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostWildcatchfishery200ResponseIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseIntermediateInnerCarbonSequestration $carbon_sequestration carbon_sequestration + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseScope1.php new file mode 100644 index 00000000..a934b098 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfishery200ResponseScope1.php @@ -0,0 +1,784 @@ + + */ +class PostWildcatchfishery200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'waste_water_co2' => 'float', + 'composted_solid_waste_co2' => 'float', + 'hfcs_refrigerant_leakage' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total_hfcs' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'waste_water_co2' => null, + 'composted_solid_waste_co2' => null, + 'hfcs_refrigerant_leakage' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total_hfcs' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'waste_water_co2' => false, + 'composted_solid_waste_co2' => false, + 'hfcs_refrigerant_leakage' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => false, + 'total_hfcs' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'waste_water_co2' => 'wasteWaterCO2', + 'composted_solid_waste_co2' => 'compostedSolidWasteCO2', + 'hfcs_refrigerant_leakage' => 'hfcsRefrigerantLeakage', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total_hfcs' => 'totalHFCs', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'waste_water_co2' => 'setWasteWaterCo2', + 'composted_solid_waste_co2' => 'setCompostedSolidWasteCo2', + 'hfcs_refrigerant_leakage' => 'setHfcsRefrigerantLeakage', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total_hfcs' => 'setTotalHfcs', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'waste_water_co2' => 'getWasteWaterCo2', + 'composted_solid_waste_co2' => 'getCompostedSolidWasteCo2', + 'hfcs_refrigerant_leakage' => 'getHfcsRefrigerantLeakage', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + 'total_hfcs' => 'getTotalHfcs', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('waste_water_co2', $data ?? [], null); + $this->setIfExists('composted_solid_waste_co2', $data ?? [], null); + $this->setIfExists('hfcs_refrigerant_leakage', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $data ?? [], null); + $this->setIfExists('total_hfcs', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['waste_water_co2'] === null) { + $invalidProperties[] = "'waste_water_co2' can't be null"; + } + if ($this->container['composted_solid_waste_co2'] === null) { + $invalidProperties[] = "'composted_solid_waste_co2' can't be null"; + } + if ($this->container['hfcs_refrigerant_leakage'] === null) { + $invalidProperties[] = "'hfcs_refrigerant_leakage' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total_hfcs'] === null) { + $invalidProperties[] = "'total_hfcs' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets waste_water_co2 + * + * @return float + */ + public function getWasteWaterCo2() + { + return $this->container['waste_water_co2']; + } + + /** + * Sets waste_water_co2 + * + * @param float $waste_water_co2 Emissions from wastewater, in tonnes-CO2e + * + * @return self + */ + public function setWasteWaterCo2($waste_water_co2) + { + if (is_null($waste_water_co2)) { + throw new \InvalidArgumentException('non-nullable waste_water_co2 cannot be null'); + } + $this->container['waste_water_co2'] = $waste_water_co2; + + return $this; + } + + /** + * Gets composted_solid_waste_co2 + * + * @return float + */ + public function getCompostedSolidWasteCo2() + { + return $this->container['composted_solid_waste_co2']; + } + + /** + * Sets composted_solid_waste_co2 + * + * @param float $composted_solid_waste_co2 Emissions from composted solid waste, in tonnes-CO2e + * + * @return self + */ + public function setCompostedSolidWasteCo2($composted_solid_waste_co2) + { + if (is_null($composted_solid_waste_co2)) { + throw new \InvalidArgumentException('non-nullable composted_solid_waste_co2 cannot be null'); + } + $this->container['composted_solid_waste_co2'] = $composted_solid_waste_co2; + + return $this; + } + + /** + * Gets hfcs_refrigerant_leakage + * + * @return float + */ + public function getHfcsRefrigerantLeakage() + { + return $this->container['hfcs_refrigerant_leakage']; + } + + /** + * Sets hfcs_refrigerant_leakage + * + * @param float $hfcs_refrigerant_leakage Emissions from refrigerant leakage, in tonnes-HFCs + * + * @return self + */ + public function setHfcsRefrigerantLeakage($hfcs_refrigerant_leakage) + { + if (is_null($hfcs_refrigerant_leakage)) { + throw new \InvalidArgumentException('non-nullable hfcs_refrigerant_leakage cannot be null'); + } + $this->container['hfcs_refrigerant_leakage'] = $hfcs_refrigerant_leakage; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total_hfcs + * + * @return float + */ + public function getTotalHfcs() + { + return $this->container['total_hfcs']; + } + + /** + * Sets total_hfcs + * + * @param float $total_hfcs Total HFCs scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalHfcs($total_hfcs) + { + if (is_null($total_hfcs)) { + throw new \InvalidArgumentException('non-nullable total_hfcs cannot be null'); + } + $this->container['total_hfcs'] = $total_hfcs; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequest.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequest.php new file mode 100644 index 00000000..9748c334 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequest.php @@ -0,0 +1,414 @@ + + */ +class PostWildcatchfisheryRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'enterprises' => '\OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'enterprises' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'enterprises' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'enterprises' => 'enterprises' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'enterprises' => 'setEnterprises' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'enterprises' => 'getEnterprises' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('enterprises', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['enterprises'] === null) { + $invalidProperties[] = "'enterprises' 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 enterprises + * + * @return \OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInner[] + */ + public function getEnterprises() + { + return $this->container['enterprises']; + } + + /** + * Sets enterprises + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInner[] $enterprises enterprises + * + * @return self + */ + public function setEnterprises($enterprises) + { + if (is_null($enterprises)) { + throw new \InvalidArgumentException('non-nullable enterprises cannot be null'); + } + $this->container['enterprises'] = $enterprises; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInner.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInner.php new file mode 100644 index 00000000..f8655222 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInner.php @@ -0,0 +1,1154 @@ + + */ +class PostWildcatchfisheryRequestEnterprisesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_request_enterprises_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'production_system' => 'string', + 'total_harvest_kg' => 'float', + 'refrigerants' => '\OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[]', + 'bait' => '\OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInnerBaitInner[]', + 'custom_bait' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[]', + 'inbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'outbound_freight' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[]', + 'total_commercial_flights_km' => 'float', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'electricity_source' => 'string', + 'fuel' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel', + 'fluid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[]', + 'solid_waste' => '\OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste', + 'carbon_offsets' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'production_system' => null, + 'total_harvest_kg' => null, + 'refrigerants' => null, + 'bait' => null, + 'custom_bait' => null, + 'inbound_freight' => null, + 'outbound_freight' => null, + 'total_commercial_flights_km' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'electricity_source' => null, + 'fuel' => null, + 'fluid_waste' => null, + 'solid_waste' => null, + 'carbon_offsets' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'production_system' => false, + 'total_harvest_kg' => false, + 'refrigerants' => false, + 'bait' => false, + 'custom_bait' => false, + 'inbound_freight' => false, + 'outbound_freight' => false, + 'total_commercial_flights_km' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'electricity_source' => false, + 'fuel' => false, + 'fluid_waste' => false, + 'solid_waste' => false, + 'carbon_offsets' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'production_system' => 'productionSystem', + 'total_harvest_kg' => 'totalHarvestKg', + 'refrigerants' => 'refrigerants', + 'bait' => 'bait', + 'custom_bait' => 'customBait', + 'inbound_freight' => 'inboundFreight', + 'outbound_freight' => 'outboundFreight', + 'total_commercial_flights_km' => 'totalCommercialFlightsKm', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'electricity_source' => 'electricitySource', + 'fuel' => 'fuel', + 'fluid_waste' => 'fluidWaste', + 'solid_waste' => 'solidWaste', + 'carbon_offsets' => 'carbonOffsets' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'production_system' => 'setProductionSystem', + 'total_harvest_kg' => 'setTotalHarvestKg', + 'refrigerants' => 'setRefrigerants', + 'bait' => 'setBait', + 'custom_bait' => 'setCustomBait', + 'inbound_freight' => 'setInboundFreight', + 'outbound_freight' => 'setOutboundFreight', + 'total_commercial_flights_km' => 'setTotalCommercialFlightsKm', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'electricity_source' => 'setElectricitySource', + 'fuel' => 'setFuel', + 'fluid_waste' => 'setFluidWaste', + 'solid_waste' => 'setSolidWaste', + 'carbon_offsets' => 'setCarbonOffsets' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'production_system' => 'getProductionSystem', + 'total_harvest_kg' => 'getTotalHarvestKg', + 'refrigerants' => 'getRefrigerants', + 'bait' => 'getBait', + 'custom_bait' => 'getCustomBait', + 'inbound_freight' => 'getInboundFreight', + 'outbound_freight' => 'getOutboundFreight', + 'total_commercial_flights_km' => 'getTotalCommercialFlightsKm', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'electricity_source' => 'getElectricitySource', + 'fuel' => 'getFuel', + 'fluid_waste' => 'getFluidWaste', + 'solid_waste' => 'getSolidWaste', + 'carbon_offsets' => 'getCarbonOffsets' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const PRODUCTION_SYSTEM_ABALONE = 'Abalone'; + public const PRODUCTION_SYSTEM_CRAB_FISHING = 'Crab Fishing'; + public const PRODUCTION_SYSTEM_DEMERSAL_TRAWL = 'Demersal Trawl'; + public const PRODUCTION_SYSTEM_GILLNET = 'Gillnet'; + public const PRODUCTION_SYSTEM_HANDLINE = 'Handline'; + public const PRODUCTION_SYSTEM_LOBSTER_POT = 'Lobster Pot'; + public const PRODUCTION_SYSTEM_LONGLINE = 'Longline'; + public const PRODUCTION_SYSTEM_NORTHERN_FISH_TRAP = 'Northern Fish Trap'; + public const PRODUCTION_SYSTEM_NORTHERN_PRAWN_TRAWL = 'Northern Prawn trawl'; + public const PRODUCTION_SYSTEM_OTTER_BOARD_TRAWL = 'Otter Board Trawl'; + public const PRODUCTION_SYSTEM_PRAWN_TRAWL_AUSTRALIAN_AVERAGE = 'Prawn trawl Australian average'; + public const PRODUCTION_SYSTEM_PURSE_SEINE = 'Purse seine'; + public const PRODUCTION_SYSTEM_SOUTHERN_OCEAN_LONGLINE = 'Southern Ocean Longline'; + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getProductionSystemAllowableValues() + { + return [ + self::PRODUCTION_SYSTEM_ABALONE, + self::PRODUCTION_SYSTEM_CRAB_FISHING, + self::PRODUCTION_SYSTEM_DEMERSAL_TRAWL, + self::PRODUCTION_SYSTEM_GILLNET, + self::PRODUCTION_SYSTEM_HANDLINE, + self::PRODUCTION_SYSTEM_LOBSTER_POT, + self::PRODUCTION_SYSTEM_LONGLINE, + self::PRODUCTION_SYSTEM_NORTHERN_FISH_TRAP, + self::PRODUCTION_SYSTEM_NORTHERN_PRAWN_TRAWL, + self::PRODUCTION_SYSTEM_OTTER_BOARD_TRAWL, + self::PRODUCTION_SYSTEM_PRAWN_TRAWL_AUSTRALIAN_AVERAGE, + self::PRODUCTION_SYSTEM_PURSE_SEINE, + self::PRODUCTION_SYSTEM_SOUTHERN_OCEAN_LONGLINE, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('production_system', $data ?? [], null); + $this->setIfExists('total_harvest_kg', $data ?? [], null); + $this->setIfExists('refrigerants', $data ?? [], null); + $this->setIfExists('bait', $data ?? [], null); + $this->setIfExists('custom_bait', $data ?? [], null); + $this->setIfExists('inbound_freight', $data ?? [], null); + $this->setIfExists('outbound_freight', $data ?? [], null); + $this->setIfExists('total_commercial_flights_km', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('fluid_waste', $data ?? [], null); + $this->setIfExists('solid_waste', $data ?? [], null); + $this->setIfExists('carbon_offsets', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['production_system'] === null) { + $invalidProperties[] = "'production_system' can't be null"; + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!is_null($this->container['production_system']) && !in_array($this->container['production_system'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'production_system', must be one of '%s'", + $this->container['production_system'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['total_harvest_kg'] === null) { + $invalidProperties[] = "'total_harvest_kg' can't be null"; + } + if ($this->container['refrigerants'] === null) { + $invalidProperties[] = "'refrigerants' can't be null"; + } + if ($this->container['bait'] === null) { + $invalidProperties[] = "'bait' can't be null"; + } + if ($this->container['custom_bait'] === null) { + $invalidProperties[] = "'custom_bait' can't be null"; + } + if ($this->container['inbound_freight'] === null) { + $invalidProperties[] = "'inbound_freight' can't be null"; + } + if ($this->container['outbound_freight'] === null) { + $invalidProperties[] = "'outbound_freight' can't be null"; + } + if ($this->container['total_commercial_flights_km'] === null) { + $invalidProperties[] = "'total_commercial_flights_km' can't be null"; + } + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['fluid_waste'] === null) { + $invalidProperties[] = "'fluid_waste' can't be null"; + } + if ($this->container['solid_waste'] === null) { + $invalidProperties[] = "'solid_waste' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets production_system + * + * @return string + */ + public function getProductionSystem() + { + return $this->container['production_system']; + } + + /** + * Sets production_system + * + * @param string $production_system Production system of the wild catch fishery enterprise + * + * @return self + */ + public function setProductionSystem($production_system) + { + if (is_null($production_system)) { + throw new \InvalidArgumentException('non-nullable production_system cannot be null'); + } + $allowedValues = $this->getProductionSystemAllowableValues(); + if (!in_array($production_system, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'production_system', must be one of '%s'", + $production_system, + implode("', '", $allowedValues) + ) + ); + } + $this->container['production_system'] = $production_system; + + return $this; + } + + /** + * Gets total_harvest_kg + * + * @return float + */ + public function getTotalHarvestKg() + { + return $this->container['total_harvest_kg']; + } + + /** + * Sets total_harvest_kg + * + * @param float $total_harvest_kg Total harvest in kg + * + * @return self + */ + public function setTotalHarvestKg($total_harvest_kg) + { + if (is_null($total_harvest_kg)) { + throw new \InvalidArgumentException('non-nullable total_harvest_kg cannot be null'); + } + $this->container['total_harvest_kg'] = $total_harvest_kg; + + return $this; + } + + /** + * Gets refrigerants + * + * @return \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] + */ + public function getRefrigerants() + { + return $this->container['refrigerants']; + } + + /** + * Sets refrigerants + * + * @param \OpenAPI\Client\Model\PostHorticultureRequestCropsInnerRefrigerantsInner[] $refrigerants Refrigerant type + * + * @return self + */ + public function setRefrigerants($refrigerants) + { + if (is_null($refrigerants)) { + throw new \InvalidArgumentException('non-nullable refrigerants cannot be null'); + } + $this->container['refrigerants'] = $refrigerants; + + return $this; + } + + /** + * Gets bait + * + * @return \OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInnerBaitInner[] + */ + public function getBait() + { + return $this->container['bait']; + } + + /** + * Sets bait + * + * @param \OpenAPI\Client\Model\PostWildcatchfisheryRequestEnterprisesInnerBaitInner[] $bait Bait purchases + * + * @return self + */ + public function setBait($bait) + { + if (is_null($bait)) { + throw new \InvalidArgumentException('non-nullable bait cannot be null'); + } + $this->container['bait'] = $bait; + + return $this; + } + + /** + * Gets custom_bait + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[] + */ + public function getCustomBait() + { + return $this->container['custom_bait']; + } + + /** + * Sets custom_bait + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerCustomBaitInner[] $custom_bait Custom bait purchases + * + * @return self + */ + public function setCustomBait($custom_bait) + { + if (is_null($custom_bait)) { + throw new \InvalidArgumentException('non-nullable custom_bait cannot be null'); + } + $this->container['custom_bait'] = $custom_bait; + + return $this; + } + + /** + * Gets inbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getInboundFreight() + { + return $this->container['inbound_freight']; + } + + /** + * Sets inbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $inbound_freight Services used to transport goods to the enterprise + * + * @return self + */ + public function setInboundFreight($inbound_freight) + { + if (is_null($inbound_freight)) { + throw new \InvalidArgumentException('non-nullable inbound_freight cannot be null'); + } + $this->container['inbound_freight'] = $inbound_freight; + + return $this; + } + + /** + * Gets outbound_freight + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] + */ + public function getOutboundFreight() + { + return $this->container['outbound_freight']; + } + + /** + * Sets outbound_freight + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerInboundFreightInner[] $outbound_freight Services used to transport goods from the enterprise + * + * @return self + */ + public function setOutboundFreight($outbound_freight) + { + if (is_null($outbound_freight)) { + throw new \InvalidArgumentException('non-nullable outbound_freight cannot be null'); + } + $this->container['outbound_freight'] = $outbound_freight; + + return $this; + } + + /** + * Gets total_commercial_flights_km + * + * @return float + */ + public function getTotalCommercialFlightsKm() + { + return $this->container['total_commercial_flights_km']; + } + + /** + * Sets total_commercial_flights_km + * + * @param float $total_commercial_flights_km Total distance of commercial flights, in km (kilometers) + * + * @return self + */ + public function setTotalCommercialFlightsKm($total_commercial_flights_km) + { + if (is_null($total_commercial_flights_km)) { + throw new \InvalidArgumentException('non-nullable total_commercial_flights_km cannot be null'); + } + $this->container['total_commercial_flights_km'] = $total_commercial_flights_km; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostWildcatchfisheryRequestEnterprisesInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostWildcatchfisheryRequestEnterprisesInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets fuel + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFuel $fuel fuel + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets fluid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] + */ + public function getFluidWaste() + { + return $this->container['fluid_waste']; + } + + /** + * Sets fluid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerFluidWasteInner[] $fluid_waste Amount of fluid waste, in kL (kilolitres) + * + * @return self + */ + public function setFluidWaste($fluid_waste) + { + if (is_null($fluid_waste)) { + throw new \InvalidArgumentException('non-nullable fluid_waste cannot be null'); + } + $this->container['fluid_waste'] = $fluid_waste; + + return $this; + } + + /** + * Gets solid_waste + * + * @return \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste + */ + public function getSolidWaste() + { + return $this->container['solid_waste']; + } + + /** + * Sets solid_waste + * + * @param \OpenAPI\Client\Model\PostAquacultureRequestEnterprisesInnerSolidWaste $solid_waste solid_waste + * + * @return self + */ + public function setSolidWaste($solid_waste) + { + if (is_null($solid_waste)) { + throw new \InvalidArgumentException('non-nullable solid_waste cannot be null'); + } + $this->container['solid_waste'] = $solid_waste; + + return $this; + } + + /** + * Gets carbon_offsets + * + * @return float|null + */ + public function getCarbonOffsets() + { + return $this->container['carbon_offsets']; + } + + /** + * Sets carbon_offsets + * + * @param float|null $carbon_offsets Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0) + * + * @return self + */ + public function setCarbonOffsets($carbon_offsets) + { + if (is_null($carbon_offsets)) { + throw new \InvalidArgumentException('non-nullable carbon_offsets cannot be null'); + } + $this->container['carbon_offsets'] = $carbon_offsets; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.php b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.php new file mode 100644 index 00000000..ac5ca0c1 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.php @@ -0,0 +1,580 @@ + + */ +class PostWildcatchfisheryRequestEnterprisesInnerBaitInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildcatchfishery_request_enterprises_inner_bait_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'purchased_tonnes' => 'float', + 'additional_ingredients' => 'float', + 'emissions_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'purchased_tonnes' => null, + 'additional_ingredients' => null, + 'emissions_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'purchased_tonnes' => false, + 'additional_ingredients' => false, + 'emissions_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'purchased_tonnes' => 'purchasedTonnes', + 'additional_ingredients' => 'additionalIngredients', + 'emissions_intensity' => 'emissionsIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'purchased_tonnes' => 'setPurchasedTonnes', + 'additional_ingredients' => 'setAdditionalIngredients', + 'emissions_intensity' => 'setEmissionsIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'purchased_tonnes' => 'getPurchasedTonnes', + 'additional_ingredients' => 'getAdditionalIngredients', + 'emissions_intensity' => 'getEmissionsIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_FISH_FRAMES = 'Fish Frames'; + public const TYPE_FISH_HEADS = 'Fish Heads'; + public const TYPE_SARDINES = 'Sardines'; + public const TYPE_SQUID = 'Squid'; + public const TYPE_WHOLE_FISH = 'Whole Fish'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_FISH_FRAMES, + self::TYPE_FISH_HEADS, + self::TYPE_SARDINES, + self::TYPE_SQUID, + self::TYPE_WHOLE_FISH, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('purchased_tonnes', $data ?? [], null); + $this->setIfExists('additional_ingredients', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], 0); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['purchased_tonnes'] === null) { + $invalidProperties[] = "'purchased_tonnes' can't be null"; + } + if ($this->container['additional_ingredients'] === null) { + $invalidProperties[] = "'additional_ingredients' can't be null"; + } + if (($this->container['additional_ingredients'] > 1)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be smaller than or equal to 1."; + } + + if (($this->container['additional_ingredients'] < 0)) { + $invalidProperties[] = "invalid value for 'additional_ingredients', must be bigger than or equal to 0."; + } + + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Bait product type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets purchased_tonnes + * + * @return float + */ + public function getPurchasedTonnes() + { + return $this->container['purchased_tonnes']; + } + + /** + * Sets purchased_tonnes + * + * @param float $purchased_tonnes Purchased product in tonnes + * + * @return self + */ + public function setPurchasedTonnes($purchased_tonnes) + { + if (is_null($purchased_tonnes)) { + throw new \InvalidArgumentException('non-nullable purchased_tonnes cannot be null'); + } + $this->container['purchased_tonnes'] = $purchased_tonnes; + + return $this; + } + + /** + * Gets additional_ingredients + * + * @return float + */ + public function getAdditionalIngredients() + { + return $this->container['additional_ingredients']; + } + + /** + * Sets additional_ingredients + * + * @param float $additional_ingredients Additional ingredient fraction, from 0 to 1 + * + * @return self + */ + public function setAdditionalIngredients($additional_ingredients) + { + if (is_null($additional_ingredients)) { + throw new \InvalidArgumentException('non-nullable additional_ingredients cannot be null'); + } + + if (($additional_ingredients > 1)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostWildcatchfisheryRequestEnterprisesInnerBaitInner., must be smaller than or equal to 1.'); + } + if (($additional_ingredients < 0)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredients when calling PostWildcatchfisheryRequestEnterprisesInnerBaitInner., must be bigger than or equal to 0.'); + } + + $this->container['additional_ingredients'] = $additional_ingredients; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of additional ingredients, in kg CO2e/kg bait (default 0) + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200Response.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200Response.php new file mode 100644 index 00000000..1158e568 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200Response.php @@ -0,0 +1,636 @@ + + */ +class PostWildseafisheries200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'scope1' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3', + 'purchased_offsets' => '\OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets', + 'intermediate' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInner[]', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet', + 'intensities' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'purchased_offsets' => null, + 'intermediate' => null, + 'net' => null, + 'intensities' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'purchased_offsets' => false, + 'intermediate' => false, + 'net' => false, + 'intensities' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'purchased_offsets' => 'purchasedOffsets', + 'intermediate' => 'intermediate', + 'net' => 'net', + 'intensities' => 'intensities' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'purchased_offsets' => 'setPurchasedOffsets', + 'intermediate' => 'setIntermediate', + 'net' => 'setNet', + 'intensities' => 'setIntensities' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'purchased_offsets' => 'getPurchasedOffsets', + 'intermediate' => 'getIntermediate', + 'net' => 'getNet', + 'intensities' => 'getIntensities' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('purchased_offsets', $data ?? [], null); + $this->setIfExists('intermediate', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['purchased_offsets'] === null) { + $invalidProperties[] = "'purchased_offsets' can't be null"; + } + if ($this->container['intermediate'] === null) { + $invalidProperties[] = "'intermediate' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' 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 scope1 + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets purchased_offsets + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets + */ + public function getPurchasedOffsets() + { + return $this->container['purchased_offsets']; + } + + /** + * Sets purchased_offsets + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets $purchased_offsets purchased_offsets + * + * @return self + */ + public function setPurchasedOffsets($purchased_offsets) + { + if (is_null($purchased_offsets)) { + throw new \InvalidArgumentException('non-nullable purchased_offsets cannot be null'); + } + $this->container['purchased_offsets'] = $purchased_offsets; + + return $this; + } + + /** + * Gets intermediate + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInner[] + */ + public function getIntermediate() + { + return $this->container['intermediate']; + } + + /** + * Sets intermediate + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInner[] $intermediate intermediate + * + * @return self + */ + public function setIntermediate($intermediate) + { + if (is_null($intermediate)) { + throw new \InvalidArgumentException('non-nullable intermediate cannot be null'); + } + $this->container['intermediate'] = $intermediate; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities[] + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities[] $intensities Emissions intensity for each enterprise (in order), in t-CO2e/t product caught + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInner.php new file mode 100644 index 00000000..f0a6f70a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInner.php @@ -0,0 +1,673 @@ + + */ +class PostWildseafisheries200ResponseIntermediateInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_200_response_intermediate_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'scope1' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1', + 'scope2' => '\OpenAPI\Client\Model\PostAquaculture200ResponseScope2', + 'scope3' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3', + 'purchased_offsets' => '\OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets', + 'carbon_sequestration' => 'float', + 'intensities' => '\OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities', + 'net' => '\OpenAPI\Client\Model\PostAquaculture200ResponseNet' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'scope1' => null, + 'scope2' => null, + 'scope3' => null, + 'purchased_offsets' => null, + 'carbon_sequestration' => null, + 'intensities' => null, + 'net' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'scope1' => false, + 'scope2' => false, + 'scope3' => false, + 'purchased_offsets' => false, + 'carbon_sequestration' => false, + 'intensities' => false, + 'net' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'scope1' => 'scope1', + 'scope2' => 'scope2', + 'scope3' => 'scope3', + 'purchased_offsets' => 'purchasedOffsets', + 'carbon_sequestration' => 'carbonSequestration', + 'intensities' => 'intensities', + 'net' => 'net' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'scope1' => 'setScope1', + 'scope2' => 'setScope2', + 'scope3' => 'setScope3', + 'purchased_offsets' => 'setPurchasedOffsets', + 'carbon_sequestration' => 'setCarbonSequestration', + 'intensities' => 'setIntensities', + 'net' => 'setNet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'scope1' => 'getScope1', + 'scope2' => 'getScope2', + 'scope3' => 'getScope3', + 'purchased_offsets' => 'getPurchasedOffsets', + 'carbon_sequestration' => 'getCarbonSequestration', + 'intensities' => 'getIntensities', + 'net' => 'getNet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('scope1', $data ?? [], null); + $this->setIfExists('scope2', $data ?? [], null); + $this->setIfExists('scope3', $data ?? [], null); + $this->setIfExists('purchased_offsets', $data ?? [], null); + $this->setIfExists('carbon_sequestration', $data ?? [], null); + $this->setIfExists('intensities', $data ?? [], null); + $this->setIfExists('net', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['scope1'] === null) { + $invalidProperties[] = "'scope1' can't be null"; + } + if ($this->container['scope2'] === null) { + $invalidProperties[] = "'scope2' can't be null"; + } + if ($this->container['scope3'] === null) { + $invalidProperties[] = "'scope3' can't be null"; + } + if ($this->container['purchased_offsets'] === null) { + $invalidProperties[] = "'purchased_offsets' can't be null"; + } + if ($this->container['carbon_sequestration'] === null) { + $invalidProperties[] = "'carbon_sequestration' can't be null"; + } + if ($this->container['intensities'] === null) { + $invalidProperties[] = "'intensities' can't be null"; + } + if ($this->container['net'] === null) { + $invalidProperties[] = "'net' 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 Unique identifier for this activity + * + * @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 scope1 + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1 + */ + public function getScope1() + { + return $this->container['scope1']; + } + + /** + * Sets scope1 + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope1 $scope1 scope1 + * + * @return self + */ + public function setScope1($scope1) + { + if (is_null($scope1)) { + throw new \InvalidArgumentException('non-nullable scope1 cannot be null'); + } + $this->container['scope1'] = $scope1; + + return $this; + } + + /** + * Gets scope2 + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 + */ + public function getScope2() + { + return $this->container['scope2']; + } + + /** + * Sets scope2 + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseScope2 $scope2 scope2 + * + * @return self + */ + public function setScope2($scope2) + { + if (is_null($scope2)) { + throw new \InvalidArgumentException('non-nullable scope2 cannot be null'); + } + $this->container['scope2'] = $scope2; + + return $this; + } + + /** + * Gets scope3 + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3 + */ + public function getScope3() + { + return $this->container['scope3']; + } + + /** + * Sets scope3 + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseScope3 $scope3 scope3 + * + * @return self + */ + public function setScope3($scope3) + { + if (is_null($scope3)) { + throw new \InvalidArgumentException('non-nullable scope3 cannot be null'); + } + $this->container['scope3'] = $scope3; + + return $this; + } + + /** + * Gets purchased_offsets + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets + */ + public function getPurchasedOffsets() + { + return $this->container['purchased_offsets']; + } + + /** + * Sets purchased_offsets + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponsePurchasedOffsets $purchased_offsets purchased_offsets + * + * @return self + */ + public function setPurchasedOffsets($purchased_offsets) + { + if (is_null($purchased_offsets)) { + throw new \InvalidArgumentException('non-nullable purchased_offsets cannot be null'); + } + $this->container['purchased_offsets'] = $purchased_offsets; + + return $this; + } + + /** + * Gets carbon_sequestration + * + * @return float + */ + public function getCarbonSequestration() + { + return $this->container['carbon_sequestration']; + } + + /** + * Sets carbon_sequestration + * + * @param float $carbon_sequestration Carbon sequestration, in tonnes-CO2e + * + * @return self + */ + public function setCarbonSequestration($carbon_sequestration) + { + if (is_null($carbon_sequestration)) { + throw new \InvalidArgumentException('non-nullable carbon_sequestration cannot be null'); + } + $this->container['carbon_sequestration'] = $carbon_sequestration; + + return $this; + } + + /** + * Gets intensities + * + * @return \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities + */ + public function getIntensities() + { + return $this->container['intensities']; + } + + /** + * Sets intensities + * + * @param \OpenAPI\Client\Model\PostWildseafisheries200ResponseIntermediateInnerIntensities $intensities intensities + * + * @return self + */ + public function setIntensities($intensities) + { + if (is_null($intensities)) { + throw new \InvalidArgumentException('non-nullable intensities cannot be null'); + } + $this->container['intensities'] = $intensities; + + return $this; + } + + /** + * Gets net + * + * @return \OpenAPI\Client\Model\PostAquaculture200ResponseNet + */ + public function getNet() + { + return $this->container['net']; + } + + /** + * Sets net + * + * @param \OpenAPI\Client\Model\PostAquaculture200ResponseNet $net net + * + * @return self + */ + public function setNet($net) + { + if (is_null($net)) { + throw new \InvalidArgumentException('non-nullable net cannot be null'); + } + $this->container['net'] = $net; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInnerIntensities.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInnerIntensities.php new file mode 100644 index 00000000..c1dd9588 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseIntermediateInnerIntensities.php @@ -0,0 +1,487 @@ + + */ +class PostWildseafisheries200ResponseIntermediateInnerIntensities implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_200_response_intermediate_inner_intensities'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'intensity_excluding_carbon_offset' => 'float', + 'intensity_including_carbon_offset' => 'float', + 'total_harvest_weight_tonnes' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'intensity_excluding_carbon_offset' => null, + 'intensity_including_carbon_offset' => null, + 'total_harvest_weight_tonnes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'intensity_excluding_carbon_offset' => false, + 'intensity_including_carbon_offset' => false, + 'total_harvest_weight_tonnes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'intensity_excluding_carbon_offset' => 'intensityExcludingCarbonOffset', + 'intensity_including_carbon_offset' => 'intensityIncludingCarbonOffset', + 'total_harvest_weight_tonnes' => 'totalHarvestWeightTonnes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'intensity_excluding_carbon_offset' => 'setIntensityExcludingCarbonOffset', + 'intensity_including_carbon_offset' => 'setIntensityIncludingCarbonOffset', + 'total_harvest_weight_tonnes' => 'setTotalHarvestWeightTonnes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'intensity_excluding_carbon_offset' => 'getIntensityExcludingCarbonOffset', + 'intensity_including_carbon_offset' => 'getIntensityIncludingCarbonOffset', + 'total_harvest_weight_tonnes' => 'getTotalHarvestWeightTonnes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('intensity_excluding_carbon_offset', $data ?? [], null); + $this->setIfExists('intensity_including_carbon_offset', $data ?? [], null); + $this->setIfExists('total_harvest_weight_tonnes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['intensity_excluding_carbon_offset'] === null) { + $invalidProperties[] = "'intensity_excluding_carbon_offset' can't be null"; + } + if ($this->container['intensity_including_carbon_offset'] === null) { + $invalidProperties[] = "'intensity_including_carbon_offset' can't be null"; + } + if ($this->container['total_harvest_weight_tonnes'] === null) { + $invalidProperties[] = "'total_harvest_weight_tonnes' 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 intensity_excluding_carbon_offset + * + * @return float + */ + public function getIntensityExcludingCarbonOffset() + { + return $this->container['intensity_excluding_carbon_offset']; + } + + /** + * Sets intensity_excluding_carbon_offset + * + * @param float $intensity_excluding_carbon_offset Wild sea fisheries emissions intensity excluding carbon offsets, in kg-CO2e/kg + * + * @return self + */ + public function setIntensityExcludingCarbonOffset($intensity_excluding_carbon_offset) + { + if (is_null($intensity_excluding_carbon_offset)) { + throw new \InvalidArgumentException('non-nullable intensity_excluding_carbon_offset cannot be null'); + } + $this->container['intensity_excluding_carbon_offset'] = $intensity_excluding_carbon_offset; + + return $this; + } + + /** + * Gets intensity_including_carbon_offset + * + * @return float + */ + public function getIntensityIncludingCarbonOffset() + { + return $this->container['intensity_including_carbon_offset']; + } + + /** + * Sets intensity_including_carbon_offset + * + * @param float $intensity_including_carbon_offset Wild sea fisheries emissions intensity including carbon offsets, in kg-CO2e/kg + * + * @return self + */ + public function setIntensityIncludingCarbonOffset($intensity_including_carbon_offset) + { + if (is_null($intensity_including_carbon_offset)) { + throw new \InvalidArgumentException('non-nullable intensity_including_carbon_offset cannot be null'); + } + $this->container['intensity_including_carbon_offset'] = $intensity_including_carbon_offset; + + return $this; + } + + /** + * Gets total_harvest_weight_tonnes + * + * @return float + */ + public function getTotalHarvestWeightTonnes() + { + return $this->container['total_harvest_weight_tonnes']; + } + + /** + * Sets total_harvest_weight_tonnes + * + * @param float $total_harvest_weight_tonnes Total harvest weight in tonnes + * + * @return self + */ + public function setTotalHarvestWeightTonnes($total_harvest_weight_tonnes) + { + if (is_null($total_harvest_weight_tonnes)) { + throw new \InvalidArgumentException('non-nullable total_harvest_weight_tonnes cannot be null'); + } + $this->container['total_harvest_weight_tonnes'] = $total_harvest_weight_tonnes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope1.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope1.php new file mode 100644 index 00000000..59f64b63 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope1.php @@ -0,0 +1,710 @@ + + */ +class PostWildseafisheries200ResponseScope1 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_200_response_scope1'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'fuel_co2' => 'float', + 'fuel_ch4' => 'float', + 'fuel_n2_o' => 'float', + 'hfcs_refrigerant_leakage' => 'float', + 'total_co2' => 'float', + 'total_ch4' => 'float', + 'total_n2_o' => 'float', + 'total_hfcs' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'fuel_co2' => null, + 'fuel_ch4' => null, + 'fuel_n2_o' => null, + 'hfcs_refrigerant_leakage' => null, + 'total_co2' => null, + 'total_ch4' => null, + 'total_n2_o' => null, + 'total_hfcs' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'fuel_co2' => false, + 'fuel_ch4' => false, + 'fuel_n2_o' => false, + 'hfcs_refrigerant_leakage' => false, + 'total_co2' => false, + 'total_ch4' => false, + 'total_n2_o' => false, + 'total_hfcs' => 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 = [ + 'fuel_co2' => 'fuelCO2', + 'fuel_ch4' => 'fuelCH4', + 'fuel_n2_o' => 'fuelN2O', + 'hfcs_refrigerant_leakage' => 'hfcsRefrigerantLeakage', + 'total_co2' => 'totalCO2', + 'total_ch4' => 'totalCH4', + 'total_n2_o' => 'totalN2O', + 'total_hfcs' => 'totalHFCs', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'fuel_co2' => 'setFuelCo2', + 'fuel_ch4' => 'setFuelCh4', + 'fuel_n2_o' => 'setFuelN2O', + 'hfcs_refrigerant_leakage' => 'setHfcsRefrigerantLeakage', + 'total_co2' => 'setTotalCo2', + 'total_ch4' => 'setTotalCh4', + 'total_n2_o' => 'setTotalN2O', + 'total_hfcs' => 'setTotalHfcs', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'fuel_co2' => 'getFuelCo2', + 'fuel_ch4' => 'getFuelCh4', + 'fuel_n2_o' => 'getFuelN2O', + 'hfcs_refrigerant_leakage' => 'getHfcsRefrigerantLeakage', + 'total_co2' => 'getTotalCo2', + 'total_ch4' => 'getTotalCh4', + 'total_n2_o' => 'getTotalN2O', + 'total_hfcs' => 'getTotalHfcs', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('fuel_co2', $data ?? [], null); + $this->setIfExists('fuel_ch4', $data ?? [], null); + $this->setIfExists('fuel_n2_o', $data ?? [], null); + $this->setIfExists('hfcs_refrigerant_leakage', $data ?? [], null); + $this->setIfExists('total_co2', $data ?? [], null); + $this->setIfExists('total_ch4', $data ?? [], null); + $this->setIfExists('total_n2_o', $data ?? [], null); + $this->setIfExists('total_hfcs', $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['fuel_co2'] === null) { + $invalidProperties[] = "'fuel_co2' can't be null"; + } + if ($this->container['fuel_ch4'] === null) { + $invalidProperties[] = "'fuel_ch4' can't be null"; + } + if ($this->container['fuel_n2_o'] === null) { + $invalidProperties[] = "'fuel_n2_o' can't be null"; + } + if ($this->container['hfcs_refrigerant_leakage'] === null) { + $invalidProperties[] = "'hfcs_refrigerant_leakage' can't be null"; + } + if ($this->container['total_co2'] === null) { + $invalidProperties[] = "'total_co2' can't be null"; + } + if ($this->container['total_ch4'] === null) { + $invalidProperties[] = "'total_ch4' can't be null"; + } + if ($this->container['total_n2_o'] === null) { + $invalidProperties[] = "'total_n2_o' can't be null"; + } + if ($this->container['total_hfcs'] === null) { + $invalidProperties[] = "'total_hfcs' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 fuel_co2 + * + * @return float + */ + public function getFuelCo2() + { + return $this->container['fuel_co2']; + } + + /** + * Sets fuel_co2 + * + * @param float $fuel_co2 CO2 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCo2($fuel_co2) + { + if (is_null($fuel_co2)) { + throw new \InvalidArgumentException('non-nullable fuel_co2 cannot be null'); + } + $this->container['fuel_co2'] = $fuel_co2; + + return $this; + } + + /** + * Gets fuel_ch4 + * + * @return float + */ + public function getFuelCh4() + { + return $this->container['fuel_ch4']; + } + + /** + * Sets fuel_ch4 + * + * @param float $fuel_ch4 CH4 emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelCh4($fuel_ch4) + { + if (is_null($fuel_ch4)) { + throw new \InvalidArgumentException('non-nullable fuel_ch4 cannot be null'); + } + $this->container['fuel_ch4'] = $fuel_ch4; + + return $this; + } + + /** + * Gets fuel_n2_o + * + * @return float + */ + public function getFuelN2O() + { + return $this->container['fuel_n2_o']; + } + + /** + * Sets fuel_n2_o + * + * @param float $fuel_n2_o N2O emissions from fuel use, in tonnes-CO2e + * + * @return self + */ + public function setFuelN2O($fuel_n2_o) + { + if (is_null($fuel_n2_o)) { + throw new \InvalidArgumentException('non-nullable fuel_n2_o cannot be null'); + } + $this->container['fuel_n2_o'] = $fuel_n2_o; + + return $this; + } + + /** + * Gets hfcs_refrigerant_leakage + * + * @return float + */ + public function getHfcsRefrigerantLeakage() + { + return $this->container['hfcs_refrigerant_leakage']; + } + + /** + * Sets hfcs_refrigerant_leakage + * + * @param float $hfcs_refrigerant_leakage Emissions from refrigerant leakage, in tonnes-HFCs + * + * @return self + */ + public function setHfcsRefrigerantLeakage($hfcs_refrigerant_leakage) + { + if (is_null($hfcs_refrigerant_leakage)) { + throw new \InvalidArgumentException('non-nullable hfcs_refrigerant_leakage cannot be null'); + } + $this->container['hfcs_refrigerant_leakage'] = $hfcs_refrigerant_leakage; + + return $this; + } + + /** + * Gets total_co2 + * + * @return float + */ + public function getTotalCo2() + { + return $this->container['total_co2']; + } + + /** + * Sets total_co2 + * + * @param float $total_co2 Total CO2 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCo2($total_co2) + { + if (is_null($total_co2)) { + throw new \InvalidArgumentException('non-nullable total_co2 cannot be null'); + } + $this->container['total_co2'] = $total_co2; + + return $this; + } + + /** + * Gets total_ch4 + * + * @return float + */ + public function getTotalCh4() + { + return $this->container['total_ch4']; + } + + /** + * Sets total_ch4 + * + * @param float $total_ch4 Total CH4 scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalCh4($total_ch4) + { + if (is_null($total_ch4)) { + throw new \InvalidArgumentException('non-nullable total_ch4 cannot be null'); + } + $this->container['total_ch4'] = $total_ch4; + + return $this; + } + + /** + * Gets total_n2_o + * + * @return float + */ + public function getTotalN2O() + { + return $this->container['total_n2_o']; + } + + /** + * Sets total_n2_o + * + * @param float $total_n2_o Total N2O scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalN2O($total_n2_o) + { + if (is_null($total_n2_o)) { + throw new \InvalidArgumentException('non-nullable total_n2_o cannot be null'); + } + $this->container['total_n2_o'] = $total_n2_o; + + return $this; + } + + /** + * Gets total_hfcs + * + * @return float + */ + public function getTotalHfcs() + { + return $this->container['total_hfcs']; + } + + /** + * Sets total_hfcs + * + * @param float $total_hfcs Total HFCs scope 1 emissions, in tonnes-CO2e + * + * @return self + */ + public function setTotalHfcs($total_hfcs) + { + if (is_null($total_hfcs)) { + throw new \InvalidArgumentException('non-nullable total_hfcs cannot be null'); + } + $this->container['total_hfcs'] = $total_hfcs; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 1 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope3.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope3.php new file mode 100644 index 00000000..04d55436 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheries200ResponseScope3.php @@ -0,0 +1,525 @@ + + */ +class PostWildseafisheries200ResponseScope3 implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_200_response_scope3'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'electricity' => 'float', + 'fuel' => 'float', + 'bait' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'electricity' => null, + 'fuel' => null, + 'bait' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'electricity' => false, + 'fuel' => false, + 'bait' => 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 = [ + 'electricity' => 'electricity', + 'fuel' => 'fuel', + 'bait' => 'bait', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'electricity' => 'setElectricity', + 'fuel' => 'setFuel', + 'bait' => 'setBait', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'electricity' => 'getElectricity', + 'fuel' => 'getFuel', + 'bait' => 'getBait', + '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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('electricity', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('bait', $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['electricity'] === null) { + $invalidProperties[] = "'electricity' can't be null"; + } + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + if ($this->container['bait'] === null) { + $invalidProperties[] = "'bait' can't be null"; + } + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' 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 electricity + * + * @return float + */ + public function getElectricity() + { + return $this->container['electricity']; + } + + /** + * Sets electricity + * + * @param float $electricity Emissions from electricity, in tonnes-CO2e + * + * @return self + */ + public function setElectricity($electricity) + { + if (is_null($electricity)) { + throw new \InvalidArgumentException('non-nullable electricity cannot be null'); + } + $this->container['electricity'] = $electricity; + + return $this; + } + + /** + * Gets fuel + * + * @return float + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param float $fuel Emissions from fuel, in tonnes-CO2e + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets bait + * + * @return float + */ + public function getBait() + { + return $this->container['bait']; + } + + /** + * Sets bait + * + * @param float $bait Emissions from purchased bait, in tonnes-CO2e + * + * @return self + */ + public function setBait($bait) + { + if (is_null($bait)) { + throw new \InvalidArgumentException('non-nullable bait cannot be null'); + } + $this->container['bait'] = $bait; + + return $this; + } + + /** + * Gets total + * + * @return float + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float $total Total scope 3 emissions, in tonnes-CO2e + * + * @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|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequest.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequest.php new file mode 100644 index 00000000..b3642abb --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequest.php @@ -0,0 +1,414 @@ + + */ +class PostWildseafisheriesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'enterprises' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'enterprises' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'enterprises' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'enterprises' => 'enterprises' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'enterprises' => 'setEnterprises' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'enterprises' => 'getEnterprises' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('enterprises', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['enterprises'] === null) { + $invalidProperties[] = "'enterprises' 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 enterprises + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInner[] + */ + public function getEnterprises() + { + return $this->container['enterprises']; + } + + /** + * Sets enterprises + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInner[] $enterprises enterprises + * + * @return self + */ + public function setEnterprises($enterprises) + { + if (is_null($enterprises)) { + throw new \InvalidArgumentException('non-nullable enterprises cannot be null'); + } + $this->container['enterprises'] = $enterprises; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInner.php new file mode 100644 index 00000000..5edf663c --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInner.php @@ -0,0 +1,1026 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'state' => 'string', + 'electricity_source' => 'string', + 'electricity_renewable' => 'float', + 'electricity_use' => 'float', + 'total_whole_weight_caught' => 'float', + 'diesel' => 'float', + 'petrol' => 'float', + 'lpg' => 'float', + 'refrigerants' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner[]', + 'transports' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerTransportsInner[]', + 'flights' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerFlightsInner[]', + 'bait' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerBaitInner[]', + 'custombait' => '\OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerCustombaitInner[]', + 'carbon_offset' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'state' => null, + 'electricity_source' => null, + 'electricity_renewable' => null, + 'electricity_use' => null, + 'total_whole_weight_caught' => null, + 'diesel' => null, + 'petrol' => null, + 'lpg' => null, + 'refrigerants' => null, + 'transports' => null, + 'flights' => null, + 'bait' => null, + 'custombait' => null, + 'carbon_offset' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'state' => false, + 'electricity_source' => false, + 'electricity_renewable' => false, + 'electricity_use' => false, + 'total_whole_weight_caught' => false, + 'diesel' => false, + 'petrol' => false, + 'lpg' => false, + 'refrigerants' => false, + 'transports' => false, + 'flights' => false, + 'bait' => false, + 'custombait' => false, + 'carbon_offset' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'state' => 'state', + 'electricity_source' => 'electricitySource', + 'electricity_renewable' => 'electricityRenewable', + 'electricity_use' => 'electricityUse', + 'total_whole_weight_caught' => 'totalWholeWeightCaught', + 'diesel' => 'diesel', + 'petrol' => 'petrol', + 'lpg' => 'lpg', + 'refrigerants' => 'refrigerants', + 'transports' => 'transports', + 'flights' => 'flights', + 'bait' => 'bait', + 'custombait' => 'custombait', + 'carbon_offset' => 'carbonOffset' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'state' => 'setState', + 'electricity_source' => 'setElectricitySource', + 'electricity_renewable' => 'setElectricityRenewable', + 'electricity_use' => 'setElectricityUse', + 'total_whole_weight_caught' => 'setTotalWholeWeightCaught', + 'diesel' => 'setDiesel', + 'petrol' => 'setPetrol', + 'lpg' => 'setLpg', + 'refrigerants' => 'setRefrigerants', + 'transports' => 'setTransports', + 'flights' => 'setFlights', + 'bait' => 'setBait', + 'custombait' => 'setCustombait', + 'carbon_offset' => 'setCarbonOffset' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'state' => 'getState', + 'electricity_source' => 'getElectricitySource', + 'electricity_renewable' => 'getElectricityRenewable', + 'electricity_use' => 'getElectricityUse', + 'total_whole_weight_caught' => 'getTotalWholeWeightCaught', + 'diesel' => 'getDiesel', + 'petrol' => 'getPetrol', + 'lpg' => 'getLpg', + 'refrigerants' => 'getRefrigerants', + 'transports' => 'getTransports', + 'flights' => 'getFlights', + 'bait' => 'getBait', + 'custombait' => 'getCustombait', + 'carbon_offset' => 'getCarbonOffset' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const STATE_NSW = 'nsw'; + public const STATE_VIC = 'vic'; + public const STATE_QLD = 'qld'; + public const STATE_SA = 'sa'; + public const STATE_WA_NW = 'wa_nw'; + public const STATE_WA_SW = 'wa_sw'; + public const STATE_TAS = 'tas'; + public const STATE_NT = 'nt'; + public const STATE_ACT = 'act'; + public const ELECTRICITY_SOURCE_STATE_GRID = 'State Grid'; + public const ELECTRICITY_SOURCE_RENEWABLE = 'Renewable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStateAllowableValues() + { + return [ + self::STATE_NSW, + self::STATE_VIC, + self::STATE_QLD, + self::STATE_SA, + self::STATE_WA_NW, + self::STATE_WA_SW, + self::STATE_TAS, + self::STATE_NT, + self::STATE_ACT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getElectricitySourceAllowableValues() + { + return [ + self::ELECTRICITY_SOURCE_STATE_GRID, + self::ELECTRICITY_SOURCE_RENEWABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('electricity_source', $data ?? [], null); + $this->setIfExists('electricity_renewable', $data ?? [], null); + $this->setIfExists('electricity_use', $data ?? [], null); + $this->setIfExists('total_whole_weight_caught', $data ?? [], null); + $this->setIfExists('diesel', $data ?? [], null); + $this->setIfExists('petrol', $data ?? [], null); + $this->setIfExists('lpg', $data ?? [], null); + $this->setIfExists('refrigerants', $data ?? [], null); + $this->setIfExists('transports', $data ?? [], null); + $this->setIfExists('flights', $data ?? [], null); + $this->setIfExists('bait', $data ?? [], null); + $this->setIfExists('custombait', $data ?? [], null); + $this->setIfExists('carbon_offset', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['state'] === null) { + $invalidProperties[] = "'state' can't be null"; + } + $allowedValues = $this->getStateAllowableValues(); + if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'state', must be one of '%s'", + $this->container['state'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_source'] === null) { + $invalidProperties[] = "'electricity_source' can't be null"; + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!is_null($this->container['electricity_source']) && !in_array($this->container['electricity_source'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'electricity_source', must be one of '%s'", + $this->container['electricity_source'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['electricity_renewable'] === null) { + $invalidProperties[] = "'electricity_renewable' can't be null"; + } + if (($this->container['electricity_renewable'] > 1)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be smaller than or equal to 1."; + } + + if (($this->container['electricity_renewable'] < 0)) { + $invalidProperties[] = "invalid value for 'electricity_renewable', must be bigger than or equal to 0."; + } + + if ($this->container['electricity_use'] === null) { + $invalidProperties[] = "'electricity_use' can't be null"; + } + if ($this->container['total_whole_weight_caught'] === null) { + $invalidProperties[] = "'total_whole_weight_caught' can't be null"; + } + if ($this->container['diesel'] === null) { + $invalidProperties[] = "'diesel' can't be null"; + } + if ($this->container['petrol'] === null) { + $invalidProperties[] = "'petrol' can't be null"; + } + if ($this->container['lpg'] === null) { + $invalidProperties[] = "'lpg' can't be null"; + } + if ($this->container['refrigerants'] === null) { + $invalidProperties[] = "'refrigerants' can't be null"; + } + if ($this->container['transports'] === null) { + $invalidProperties[] = "'transports' can't be null"; + } + if ($this->container['flights'] === null) { + $invalidProperties[] = "'flights' can't be null"; + } + if ($this->container['bait'] === null) { + $invalidProperties[] = "'bait' can't be null"; + } + if ($this->container['custombait'] === null) { + $invalidProperties[] = "'custombait' can't be null"; + } + if ($this->container['carbon_offset'] === null) { + $invalidProperties[] = "'carbon_offset' 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|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Unique identifier for this activity + * + * @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 state + * + * @return string + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param string $state What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $allowedValues = $this->getStateAllowableValues(); + if (!in_array($state, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'state', must be one of '%s'", + $state, + implode("', '", $allowedValues) + ) + ); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets electricity_source + * + * @return string + */ + public function getElectricitySource() + { + return $this->container['electricity_source']; + } + + /** + * Sets electricity_source + * + * @param string $electricity_source Source of electricity + * + * @return self + */ + public function setElectricitySource($electricity_source) + { + if (is_null($electricity_source)) { + throw new \InvalidArgumentException('non-nullable electricity_source cannot be null'); + } + $allowedValues = $this->getElectricitySourceAllowableValues(); + if (!in_array($electricity_source, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'electricity_source', must be one of '%s'", + $electricity_source, + implode("', '", $allowedValues) + ) + ); + } + $this->container['electricity_source'] = $electricity_source; + + return $this; + } + + /** + * Gets electricity_renewable + * + * @return float + */ + public function getElectricityRenewable() + { + return $this->container['electricity_renewable']; + } + + /** + * Sets electricity_renewable + * + * @param float $electricity_renewable Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable` + * + * @return self + */ + public function setElectricityRenewable($electricity_renewable) + { + if (is_null($electricity_renewable)) { + throw new \InvalidArgumentException('non-nullable electricity_renewable cannot be null'); + } + + if (($electricity_renewable > 1)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostWildseafisheriesRequestEnterprisesInner., must be smaller than or equal to 1.'); + } + if (($electricity_renewable < 0)) { + throw new \InvalidArgumentException('invalid value for $electricity_renewable when calling PostWildseafisheriesRequestEnterprisesInner., must be bigger than or equal to 0.'); + } + + $this->container['electricity_renewable'] = $electricity_renewable; + + return $this; + } + + /** + * Gets electricity_use + * + * @return float + */ + public function getElectricityUse() + { + return $this->container['electricity_use']; + } + + /** + * Sets electricity_use + * + * @param float $electricity_use Electricity use in KWh (kilowatt hours) + * + * @return self + */ + public function setElectricityUse($electricity_use) + { + if (is_null($electricity_use)) { + throw new \InvalidArgumentException('non-nullable electricity_use cannot be null'); + } + $this->container['electricity_use'] = $electricity_use; + + return $this; + } + + /** + * Gets total_whole_weight_caught + * + * @return float + */ + public function getTotalWholeWeightCaught() + { + return $this->container['total_whole_weight_caught']; + } + + /** + * Sets total_whole_weight_caught + * + * @param float $total_whole_weight_caught Total whole weight caught in kg + * + * @return self + */ + public function setTotalWholeWeightCaught($total_whole_weight_caught) + { + if (is_null($total_whole_weight_caught)) { + throw new \InvalidArgumentException('non-nullable total_whole_weight_caught cannot be null'); + } + $this->container['total_whole_weight_caught'] = $total_whole_weight_caught; + + return $this; + } + + /** + * Gets diesel + * + * @return float + */ + public function getDiesel() + { + return $this->container['diesel']; + } + + /** + * Sets diesel + * + * @param float $diesel Diesel usage in L (litres) + * + * @return self + */ + public function setDiesel($diesel) + { + if (is_null($diesel)) { + throw new \InvalidArgumentException('non-nullable diesel cannot be null'); + } + $this->container['diesel'] = $diesel; + + return $this; + } + + /** + * Gets petrol + * + * @return float + */ + public function getPetrol() + { + return $this->container['petrol']; + } + + /** + * Sets petrol + * + * @param float $petrol Petrol usage in L (litres) + * + * @return self + */ + public function setPetrol($petrol) + { + if (is_null($petrol)) { + throw new \InvalidArgumentException('non-nullable petrol cannot be null'); + } + $this->container['petrol'] = $petrol; + + return $this; + } + + /** + * Gets lpg + * + * @return float + */ + public function getLpg() + { + return $this->container['lpg']; + } + + /** + * Sets lpg + * + * @param float $lpg LPG Fuel usage in L (litres) + * + * @return self + */ + public function setLpg($lpg) + { + if (is_null($lpg)) { + throw new \InvalidArgumentException('non-nullable lpg cannot be null'); + } + $this->container['lpg'] = $lpg; + + return $this; + } + + /** + * Gets refrigerants + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner[] + */ + public function getRefrigerants() + { + return $this->container['refrigerants']; + } + + /** + * Sets refrigerants + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner[] $refrigerants refrigerants + * + * @return self + */ + public function setRefrigerants($refrigerants) + { + if (is_null($refrigerants)) { + throw new \InvalidArgumentException('non-nullable refrigerants cannot be null'); + } + $this->container['refrigerants'] = $refrigerants; + + return $this; + } + + /** + * Gets transports + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerTransportsInner[] + */ + public function getTransports() + { + return $this->container['transports']; + } + + /** + * Sets transports + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerTransportsInner[] $transports Transportation + * + * @return self + */ + public function setTransports($transports) + { + if (is_null($transports)) { + throw new \InvalidArgumentException('non-nullable transports cannot be null'); + } + $this->container['transports'] = $transports; + + return $this; + } + + /** + * Gets flights + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerFlightsInner[] + */ + public function getFlights() + { + return $this->container['flights']; + } + + /** + * Sets flights + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerFlightsInner[] $flights CommercialFlight + * + * @return self + */ + public function setFlights($flights) + { + if (is_null($flights)) { + throw new \InvalidArgumentException('non-nullable flights cannot be null'); + } + $this->container['flights'] = $flights; + + return $this; + } + + /** + * Gets bait + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerBaitInner[] + */ + public function getBait() + { + return $this->container['bait']; + } + + /** + * Sets bait + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerBaitInner[] $bait Bait + * + * @return self + */ + public function setBait($bait) + { + if (is_null($bait)) { + throw new \InvalidArgumentException('non-nullable bait cannot be null'); + } + $this->container['bait'] = $bait; + + return $this; + } + + /** + * Gets custombait + * + * @return \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerCustombaitInner[] + */ + public function getCustombait() + { + return $this->container['custombait']; + } + + /** + * Sets custombait + * + * @param \OpenAPI\Client\Model\PostWildseafisheriesRequestEnterprisesInnerCustombaitInner[] $custombait Custom bait + * + * @return self + */ + public function setCustombait($custombait) + { + if (is_null($custombait)) { + throw new \InvalidArgumentException('non-nullable custombait cannot be null'); + } + $this->container['custombait'] = $custombait; + + return $this; + } + + /** + * Gets carbon_offset + * + * @return float + */ + public function getCarbonOffset() + { + return $this->container['carbon_offset']; + } + + /** + * Sets carbon_offset + * + * @param float $carbon_offset Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0) + * + * @return self + */ + public function setCarbonOffset($carbon_offset) + { + if (is_null($carbon_offset)) { + throw new \InvalidArgumentException('non-nullable carbon_offset cannot be null'); + } + $this->container['carbon_offset'] = $carbon_offset; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerBaitInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerBaitInner.php new file mode 100644 index 00000000..fec0d22a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerBaitInner.php @@ -0,0 +1,580 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInnerBaitInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner_bait_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'purchased' => 'float', + 'additional_ingredient' => 'float', + 'emissions_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'purchased' => null, + 'additional_ingredient' => null, + 'emissions_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'purchased' => false, + 'additional_ingredient' => false, + 'emissions_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'purchased' => 'purchased', + 'additional_ingredient' => 'additionalIngredient', + 'emissions_intensity' => 'emissionsIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'purchased' => 'setPurchased', + 'additional_ingredient' => 'setAdditionalIngredient', + 'emissions_intensity' => 'setEmissionsIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'purchased' => 'getPurchased', + 'additional_ingredient' => 'getAdditionalIngredient', + 'emissions_intensity' => 'getEmissionsIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_FISH_FRAMES = 'Fish Frames'; + public const TYPE_FISH_HEADS = 'Fish Heads'; + public const TYPE_SARDINES = 'Sardines'; + public const TYPE_SQUID = 'Squid'; + public const TYPE_WHOLE_FISH = 'Whole Fish'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_FISH_FRAMES, + self::TYPE_FISH_HEADS, + self::TYPE_SARDINES, + self::TYPE_SQUID, + self::TYPE_WHOLE_FISH, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('purchased', $data ?? [], null); + $this->setIfExists('additional_ingredient', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['purchased'] === null) { + $invalidProperties[] = "'purchased' can't be null"; + } + if ($this->container['additional_ingredient'] === null) { + $invalidProperties[] = "'additional_ingredient' can't be null"; + } + if (($this->container['additional_ingredient'] > 1)) { + $invalidProperties[] = "invalid value for 'additional_ingredient', must be smaller than or equal to 1."; + } + + if (($this->container['additional_ingredient'] < 0)) { + $invalidProperties[] = "invalid value for 'additional_ingredient', must be bigger than or equal to 0."; + } + + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Bait product type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets purchased + * + * @return float + */ + public function getPurchased() + { + return $this->container['purchased']; + } + + /** + * Sets purchased + * + * @param float $purchased Purchased product in tonnes + * + * @return self + */ + public function setPurchased($purchased) + { + if (is_null($purchased)) { + throw new \InvalidArgumentException('non-nullable purchased cannot be null'); + } + $this->container['purchased'] = $purchased; + + return $this; + } + + /** + * Gets additional_ingredient + * + * @return float + */ + public function getAdditionalIngredient() + { + return $this->container['additional_ingredient']; + } + + /** + * Sets additional_ingredient + * + * @param float $additional_ingredient Additional ingredient fraction, from 0 to 1 + * + * @return self + */ + public function setAdditionalIngredient($additional_ingredient) + { + if (is_null($additional_ingredient)) { + throw new \InvalidArgumentException('non-nullable additional_ingredient cannot be null'); + } + + if (($additional_ingredient > 1)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredient when calling PostWildseafisheriesRequestEnterprisesInnerBaitInner., must be smaller than or equal to 1.'); + } + if (($additional_ingredient < 0)) { + throw new \InvalidArgumentException('invalid value for $additional_ingredient when calling PostWildseafisheriesRequestEnterprisesInnerBaitInner., must be bigger than or equal to 0.'); + } + + $this->container['additional_ingredient'] = $additional_ingredient; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of product, in kg CO2e/kg + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.php new file mode 100644 index 00000000..785bcd22 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.php @@ -0,0 +1,450 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInnerCustombaitInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner_custombait_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'purchased' => 'float', + 'emissions_intensity' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'purchased' => null, + 'emissions_intensity' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'purchased' => false, + 'emissions_intensity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'purchased' => 'purchased', + 'emissions_intensity' => 'emissionsIntensity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'purchased' => 'setPurchased', + 'emissions_intensity' => 'setEmissionsIntensity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'purchased' => 'getPurchased', + 'emissions_intensity' => 'getEmissionsIntensity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('purchased', $data ?? [], null); + $this->setIfExists('emissions_intensity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['purchased'] === null) { + $invalidProperties[] = "'purchased' can't be null"; + } + if ($this->container['emissions_intensity'] === null) { + $invalidProperties[] = "'emissions_intensity' 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 purchased + * + * @return float + */ + public function getPurchased() + { + return $this->container['purchased']; + } + + /** + * Sets purchased + * + * @param float $purchased Purchased product in tonnes + * + * @return self + */ + public function setPurchased($purchased) + { + if (is_null($purchased)) { + throw new \InvalidArgumentException('non-nullable purchased cannot be null'); + } + $this->container['purchased'] = $purchased; + + return $this; + } + + /** + * Gets emissions_intensity + * + * @return float + */ + public function getEmissionsIntensity() + { + return $this->container['emissions_intensity']; + } + + /** + * Sets emissions_intensity + * + * @param float $emissions_intensity Emissions intensity of product, in kg CO2e/kg + * + * @return self + */ + public function setEmissionsIntensity($emissions_intensity) + { + if (is_null($emissions_intensity)) { + throw new \InvalidArgumentException('non-nullable emissions_intensity cannot be null'); + } + $this->container['emissions_intensity'] = $emissions_intensity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.php new file mode 100644 index 00000000..5fca140a --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.php @@ -0,0 +1,450 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInnerFlightsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner_flights_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'commercial_flight_passengers' => 'float', + 'total_flight_distance' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'commercial_flight_passengers' => null, + 'total_flight_distance' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'commercial_flight_passengers' => false, + 'total_flight_distance' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'commercial_flight_passengers' => 'commercialFlightPassengers', + 'total_flight_distance' => 'totalFlightDistance' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'commercial_flight_passengers' => 'setCommercialFlightPassengers', + 'total_flight_distance' => 'setTotalFlightDistance' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'commercial_flight_passengers' => 'getCommercialFlightPassengers', + 'total_flight_distance' => 'getTotalFlightDistance' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('commercial_flight_passengers', $data ?? [], null); + $this->setIfExists('total_flight_distance', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['commercial_flight_passengers'] === null) { + $invalidProperties[] = "'commercial_flight_passengers' can't be null"; + } + if ($this->container['total_flight_distance'] === null) { + $invalidProperties[] = "'total_flight_distance' 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 commercial_flight_passengers + * + * @return float + */ + public function getCommercialFlightPassengers() + { + return $this->container['commercial_flight_passengers']; + } + + /** + * Sets commercial_flight_passengers + * + * @param float $commercial_flight_passengers Commercial flight passengers per year + * + * @return self + */ + public function setCommercialFlightPassengers($commercial_flight_passengers) + { + if (is_null($commercial_flight_passengers)) { + throw new \InvalidArgumentException('non-nullable commercial_flight_passengers cannot be null'); + } + $this->container['commercial_flight_passengers'] = $commercial_flight_passengers; + + return $this; + } + + /** + * Gets total_flight_distance + * + * @return float + */ + public function getTotalFlightDistance() + { + return $this->container['total_flight_distance']; + } + + /** + * Sets total_flight_distance + * + * @param float $total_flight_distance Total commercial flight distance in km + * + * @return self + */ + public function setTotalFlightDistance($total_flight_distance) + { + if (is_null($total_flight_distance)) { + throw new \InvalidArgumentException('non-nullable total_flight_distance cannot be null'); + } + $this->container['total_flight_distance'] = $total_flight_distance; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.php new file mode 100644 index 00000000..78cf1d72 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.php @@ -0,0 +1,666 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner_refrigerants_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'refrigerant' => 'string', + 'annual_recharge' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'refrigerant' => null, + 'annual_recharge' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'refrigerant' => false, + 'annual_recharge' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'refrigerant' => 'refrigerant', + 'annual_recharge' => 'annualRecharge' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'refrigerant' => 'setRefrigerant', + 'annual_recharge' => 'setAnnualRecharge' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'refrigerant' => 'getRefrigerant', + 'annual_recharge' => 'getAnnualRecharge' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const REFRIGERANT_HFC_23 = 'HFC-23'; + public const REFRIGERANT_HFC_32 = 'HFC-32'; + public const REFRIGERANT_HFC_41 = 'HFC-41'; + public const REFRIGERANT_HFC_43_10MEE = 'HFC-43-10mee'; + public const REFRIGERANT_HFC_125 = 'HFC-125'; + public const REFRIGERANT_HFC_134 = 'HFC-134'; + public const REFRIGERANT_HFC_134A = 'HFC-134a'; + public const REFRIGERANT_HFC_143 = 'HFC-143'; + public const REFRIGERANT_HFC_143A = 'HFC-143a'; + public const REFRIGERANT_HFC_152A = 'HFC-152a'; + public const REFRIGERANT_HFC_227EA = 'HFC-227ea'; + public const REFRIGERANT_HFC_236FA = 'HFC-236fa'; + public const REFRIGERANT_HFC_245CA = 'HFC-245ca'; + public const REFRIGERANT_HFC_245FA = 'HFC-245fa'; + public const REFRIGERANT_HFC_365MFC = 'HFC-365mfc'; + public const REFRIGERANT_R438_A = 'R438A'; + public const REFRIGERANT_R448_A = 'R448A'; + public const REFRIGERANT_R_22 = 'R-22'; + public const REFRIGERANT_AMMONIA__R_717 = 'Ammonia (R-717)'; + public const REFRIGERANT_R_11 = 'R-11'; + public const REFRIGERANT_R_12 = 'R-12'; + public const REFRIGERANT_R_13 = 'R-13'; + public const REFRIGERANT_R_23 = 'R-23'; + public const REFRIGERANT_R_32 = 'R-32'; + public const REFRIGERANT_R_113 = 'R-113'; + public const REFRIGERANT_R_114 = 'R-114'; + public const REFRIGERANT_R_115 = 'R-115'; + public const REFRIGERANT_R_116 = 'R-116'; + public const REFRIGERANT_R_123 = 'R-123'; + public const REFRIGERANT_R_124 = 'R-124'; + public const REFRIGERANT_R_125 = 'R-125'; + public const REFRIGERANT_R_134A = 'R-134a'; + public const REFRIGERANT_R_141B = 'R-141b'; + public const REFRIGERANT_R_142B = 'R-142b'; + public const REFRIGERANT_R_143A = 'R-143a'; + public const REFRIGERANT_R_152A = 'R-152a'; + public const REFRIGERANT_R_218 = 'R-218'; + public const REFRIGERANT_R_227EA = 'R-227ea'; + public const REFRIGERANT_R_236FA = 'R-236fa'; + public const REFRIGERANT_R_245CA = 'R-245ca'; + public const REFRIGERANT_R_245FA = 'R-245fa'; + public const REFRIGERANT_R_C318 = 'R-C318'; + public const REFRIGERANT_R_401_A = 'R-401A'; + public const REFRIGERANT_R_401_B = 'R-401B'; + public const REFRIGERANT_R_401_C = 'R-401C'; + public const REFRIGERANT_R_402_A = 'R-402A'; + public const REFRIGERANT_R_402_B = 'R-402B'; + public const REFRIGERANT_R_403_A = 'R-403A'; + public const REFRIGERANT_R_403_B = 'R-403B'; + public const REFRIGERANT_R_404_A = 'R-404A'; + public const REFRIGERANT_R_405_A = 'R-405A'; + public const REFRIGERANT_R_406_A = 'R-406A'; + public const REFRIGERANT_R_407_A = 'R-407A'; + public const REFRIGERANT_R_407_B = 'R-407B'; + public const REFRIGERANT_R_407_C = 'R-407C'; + public const REFRIGERANT_R_407_D = 'R-407D'; + public const REFRIGERANT_R_407_E = 'R-407E'; + public const REFRIGERANT_R_408_A = 'R-408A'; + public const REFRIGERANT_R_409_A = 'R-409A'; + public const REFRIGERANT_R_409_B = 'R-409B'; + public const REFRIGERANT_R_410_A = 'R-410A'; + public const REFRIGERANT_R_411_A = 'R-411A'; + public const REFRIGERANT_R_411_B = 'R-411B'; + public const REFRIGERANT_R_412_A = 'R-412A'; + public const REFRIGERANT_R_413_A = 'R-413A'; + public const REFRIGERANT_R_414_A = 'R-414A'; + public const REFRIGERANT_R_414_B = 'R-414B'; + public const REFRIGERANT_R_415_A = 'R-415A'; + public const REFRIGERANT_R_415_B = 'R-415B'; + public const REFRIGERANT_R_416_A = 'R-416A'; + public const REFRIGERANT_R_417_A = 'R-417A'; + public const REFRIGERANT_R_418_A = 'R-418A'; + public const REFRIGERANT_R_419_A = 'R-419A'; + public const REFRIGERANT_R_420_A = 'R-420A'; + public const REFRIGERANT_R_421_A = 'R-421A'; + public const REFRIGERANT_R_421_B = 'R-421B'; + public const REFRIGERANT_R_422_A = 'R-422A'; + public const REFRIGERANT_R_422_B = 'R-422B'; + public const REFRIGERANT_R_422_C = 'R-422C'; + public const REFRIGERANT_R_422_D = 'R-422D'; + public const REFRIGERANT_R_423_A = 'R-423A'; + public const REFRIGERANT_R_424_A = 'R-424A'; + public const REFRIGERANT_R_425_A = 'R-425A'; + public const REFRIGERANT_R_426_A = 'R-426A'; + public const REFRIGERANT_R_427_A = 'R-427A'; + public const REFRIGERANT_R_428_A = 'R-428A'; + public const REFRIGERANT_R_500 = 'R-500'; + public const REFRIGERANT_R_502 = 'R-502'; + public const REFRIGERANT_R_503 = 'R-503'; + public const REFRIGERANT_R_507_A = 'R-507A'; + public const REFRIGERANT_R_508_A = 'R-508A'; + public const REFRIGERANT_R_508_B = 'R-508B'; + public const REFRIGERANT_R_509_A = 'R-509A'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getRefrigerantAllowableValues() + { + return [ + self::REFRIGERANT_HFC_23, + self::REFRIGERANT_HFC_32, + self::REFRIGERANT_HFC_41, + self::REFRIGERANT_HFC_43_10MEE, + self::REFRIGERANT_HFC_125, + self::REFRIGERANT_HFC_134, + self::REFRIGERANT_HFC_134A, + self::REFRIGERANT_HFC_143, + self::REFRIGERANT_HFC_143A, + self::REFRIGERANT_HFC_152A, + self::REFRIGERANT_HFC_227EA, + self::REFRIGERANT_HFC_236FA, + self::REFRIGERANT_HFC_245CA, + self::REFRIGERANT_HFC_245FA, + self::REFRIGERANT_HFC_365MFC, + self::REFRIGERANT_R438_A, + self::REFRIGERANT_R448_A, + self::REFRIGERANT_R_22, + self::REFRIGERANT_AMMONIA__R_717, + self::REFRIGERANT_R_11, + self::REFRIGERANT_R_12, + self::REFRIGERANT_R_13, + self::REFRIGERANT_R_23, + self::REFRIGERANT_R_32, + self::REFRIGERANT_R_113, + self::REFRIGERANT_R_114, + self::REFRIGERANT_R_115, + self::REFRIGERANT_R_116, + self::REFRIGERANT_R_123, + self::REFRIGERANT_R_124, + self::REFRIGERANT_R_125, + self::REFRIGERANT_R_134A, + self::REFRIGERANT_R_141B, + self::REFRIGERANT_R_142B, + self::REFRIGERANT_R_143A, + self::REFRIGERANT_R_152A, + self::REFRIGERANT_R_218, + self::REFRIGERANT_R_227EA, + self::REFRIGERANT_R_236FA, + self::REFRIGERANT_R_245CA, + self::REFRIGERANT_R_245FA, + self::REFRIGERANT_R_C318, + self::REFRIGERANT_R_401_A, + self::REFRIGERANT_R_401_B, + self::REFRIGERANT_R_401_C, + self::REFRIGERANT_R_402_A, + self::REFRIGERANT_R_402_B, + self::REFRIGERANT_R_403_A, + self::REFRIGERANT_R_403_B, + self::REFRIGERANT_R_404_A, + self::REFRIGERANT_R_405_A, + self::REFRIGERANT_R_406_A, + self::REFRIGERANT_R_407_A, + self::REFRIGERANT_R_407_B, + self::REFRIGERANT_R_407_C, + self::REFRIGERANT_R_407_D, + self::REFRIGERANT_R_407_E, + self::REFRIGERANT_R_408_A, + self::REFRIGERANT_R_409_A, + self::REFRIGERANT_R_409_B, + self::REFRIGERANT_R_410_A, + self::REFRIGERANT_R_411_A, + self::REFRIGERANT_R_411_B, + self::REFRIGERANT_R_412_A, + self::REFRIGERANT_R_413_A, + self::REFRIGERANT_R_414_A, + self::REFRIGERANT_R_414_B, + self::REFRIGERANT_R_415_A, + self::REFRIGERANT_R_415_B, + self::REFRIGERANT_R_416_A, + self::REFRIGERANT_R_417_A, + self::REFRIGERANT_R_418_A, + self::REFRIGERANT_R_419_A, + self::REFRIGERANT_R_420_A, + self::REFRIGERANT_R_421_A, + self::REFRIGERANT_R_421_B, + self::REFRIGERANT_R_422_A, + self::REFRIGERANT_R_422_B, + self::REFRIGERANT_R_422_C, + self::REFRIGERANT_R_422_D, + self::REFRIGERANT_R_423_A, + self::REFRIGERANT_R_424_A, + self::REFRIGERANT_R_425_A, + self::REFRIGERANT_R_426_A, + self::REFRIGERANT_R_427_A, + self::REFRIGERANT_R_428_A, + self::REFRIGERANT_R_500, + self::REFRIGERANT_R_502, + self::REFRIGERANT_R_503, + self::REFRIGERANT_R_507_A, + self::REFRIGERANT_R_508_A, + self::REFRIGERANT_R_508_B, + self::REFRIGERANT_R_509_A, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('refrigerant', $data ?? [], null); + $this->setIfExists('annual_recharge', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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['refrigerant'] === null) { + $invalidProperties[] = "'refrigerant' can't be null"; + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!is_null($this->container['refrigerant']) && !in_array($this->container['refrigerant'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'refrigerant', must be one of '%s'", + $this->container['refrigerant'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['annual_recharge'] === null) { + $invalidProperties[] = "'annual_recharge' 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 refrigerant + * + * @return string + */ + public function getRefrigerant() + { + return $this->container['refrigerant']; + } + + /** + * Sets refrigerant + * + * @param string $refrigerant Refrigerant type + * + * @return self + */ + public function setRefrigerant($refrigerant) + { + if (is_null($refrigerant)) { + throw new \InvalidArgumentException('non-nullable refrigerant cannot be null'); + } + $allowedValues = $this->getRefrigerantAllowableValues(); + if (!in_array($refrigerant, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'refrigerant', must be one of '%s'", + $refrigerant, + implode("', '", $allowedValues) + ) + ); + } + $this->container['refrigerant'] = $refrigerant; + + return $this; + } + + /** + * Gets annual_recharge + * + * @return float + */ + public function getAnnualRecharge() + { + return $this->container['annual_recharge']; + } + + /** + * Sets annual_recharge + * + * @param float $annual_recharge Amount of refrigerant annually recharged, kg product/year + * + * @return self + */ + public function setAnnualRecharge($annual_recharge) + { + if (is_null($annual_recharge)) { + throw new \InvalidArgumentException('non-nullable annual_recharge cannot be null'); + } + $this->container['annual_recharge'] = $annual_recharge; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.php b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.php new file mode 100644 index 00000000..069dede0 --- /dev/null +++ b/examples/php-api-client/api-client/lib/Model/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.php @@ -0,0 +1,585 @@ + + */ +class PostWildseafisheriesRequestEnterprisesInnerTransportsInner implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'post_wildseafisheries_request_enterprises_inner_transports_inner'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'fuel' => 'string', + 'distance' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'fuel' => null, + 'distance' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'fuel' => false, + 'distance' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->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', + 'fuel' => 'fuel', + 'distance' => 'distance' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'fuel' => 'setFuel', + 'distance' => 'setDistance' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'fuel' => 'getFuel', + 'distance' => 'getDistance' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_NONE = 'None'; + public const TYPE_SMALL_CAR = 'Small Car'; + public const TYPE_MEDIUM_CAR = 'Medium Car'; + public const TYPE_LARGE_CAR = 'Large Car'; + public const TYPE_COURIER_VAN_UTILITY = 'Courier Van-Utility'; + public const TYPE__4_WD_MID_SIZE = '4WD Mid Size'; + public const TYPE_LIGHT_RIGID = 'Light Rigid'; + public const TYPE_MEDIUM_RIGID = 'Medium Rigid'; + public const TYPE_HEAVY_RIGID = 'Heavy Rigid'; + public const TYPE_HEAVY_BUS = 'Heavy Bus'; + public const FUEL_GASOLINE = 'Gasoline'; + public const FUEL_DIESEL_OIL = 'Diesel oil'; + public const FUEL_LIQUEFIED_PETROLEUM_GAS__LPG = 'Liquefied petroleum gas (LPG)'; + public const FUEL_FUEL_OIL = 'Fuel oil'; + public const FUEL_ETHANOL = 'Ethanol'; + public const FUEL_BIODIESEL = 'Biodiesel'; + public const FUEL_RENEWABLE_DIESEL = 'Renewable diesel'; + public const FUEL_OTHER_BIOFUELS = 'Other biofuels'; + public const FUEL_LIQUIFIED_NATURAL_GAS = 'Liquified natural gas'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_NONE, + self::TYPE_SMALL_CAR, + self::TYPE_MEDIUM_CAR, + self::TYPE_LARGE_CAR, + self::TYPE_COURIER_VAN_UTILITY, + self::TYPE__4_WD_MID_SIZE, + self::TYPE_LIGHT_RIGID, + self::TYPE_MEDIUM_RIGID, + self::TYPE_HEAVY_RIGID, + self::TYPE_HEAVY_BUS, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getFuelAllowableValues() + { + return [ + self::FUEL_GASOLINE, + self::FUEL_DIESEL_OIL, + self::FUEL_LIQUEFIED_PETROLEUM_GAS__LPG, + self::FUEL_FUEL_OIL, + self::FUEL_ETHANOL, + self::FUEL_BIODIESEL, + self::FUEL_RENEWABLE_DIESEL, + self::FUEL_OTHER_BIOFUELS, + self::FUEL_LIQUIFIED_NATURAL_GAS, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('fuel', $data ?? [], null); + $this->setIfExists('distance', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $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"; + } + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['fuel'] === null) { + $invalidProperties[] = "'fuel' can't be null"; + } + $allowedValues = $this->getFuelAllowableValues(); + if (!is_null($this->container['fuel']) && !in_array($this->container['fuel'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'fuel', must be one of '%s'", + $this->container['fuel'], + implode("', '", $allowedValues) + ); + } + + if ($this->container['distance'] === null) { + $invalidProperties[] = "'distance' 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 string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type Transport type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets fuel + * + * @return string + */ + public function getFuel() + { + return $this->container['fuel']; + } + + /** + * Sets fuel + * + * @param string $fuel Fuel type + * + * @return self + */ + public function setFuel($fuel) + { + if (is_null($fuel)) { + throw new \InvalidArgumentException('non-nullable fuel cannot be null'); + } + $allowedValues = $this->getFuelAllowableValues(); + if (!in_array($fuel, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'fuel', must be one of '%s'", + $fuel, + implode("', '", $allowedValues) + ) + ); + } + $this->container['fuel'] = $fuel; + + return $this; + } + + /** + * Gets distance + * + * @return float + */ + public function getDistance() + { + return $this->container['distance']; + } + + /** + * Sets distance + * + * @param float $distance Distance in km + * + * @return self + */ + public function setDistance($distance) + { + if (is_null($distance)) { + throw new \InvalidArgumentException('non-nullable distance cannot be null'); + } + $this->container['distance'] = $distance; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/examples/php-api-client/api-client/lib/ObjectSerializer.php b/examples/php-api-client/api-client/lib/ObjectSerializer.php new file mode 100644 index 00000000..efe725da --- /dev/null +++ b/examples/php-api-client/api-client/lib/ObjectSerializer.php @@ -0,0 +1,600 @@ +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 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[]|null $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/examples/php-api-client/api-client/phpunit.xml.dist b/examples/php-api-client/api-client/phpunit.xml.dist new file mode 100644 index 00000000..485899aa --- /dev/null +++ b/examples/php-api-client/api-client/phpunit.xml.dist @@ -0,0 +1,18 @@ + + + + + ./lib/Api + ./lib/Model + + + + + ./test/Api + ./test/Model + + + + + + diff --git a/examples/php-api-client/api-client/run_test.sh b/examples/php-api-client/api-client/run_test.sh new file mode 100755 index 00000000..cb1cecc6 --- /dev/null +++ b/examples/php-api-client/api-client/run_test.sh @@ -0,0 +1 @@ +php ./example.php \ No newline at end of file diff --git a/examples/php-api-client/api-client/setup_local.sh b/examples/php-api-client/api-client/setup_local.sh new file mode 100755 index 00000000..03105477 --- /dev/null +++ b/examples/php-api-client/api-client/setup_local.sh @@ -0,0 +1 @@ +composer install \ No newline at end of file diff --git a/examples/php-api-client/generate.sh b/examples/php-api-client/generate.sh new file mode 100755 index 00000000..60927e7f --- /dev/null +++ b/examples/php-api-client/generate.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e +API_CLIENT_DIR=api-client +API_VERSION=3.0.0 +rm -rf $API_CLIENT_DIR + +npm -g install @openapitools/openapi-generator-cli +openapi-generator-cli generate \ + -i https://d2awla29kxgk7i.cloudfront.net/api/$API_VERSION/openapi.json \ + -g php \ + -o $API_CLIENT_DIR \ + --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false + +cp resources/* $API_CLIENT_DIR/ + +cd $API_CLIENT_DIR +./setup_local.sh +./run_test.sh \ No newline at end of file diff --git a/examples/php-api-client/resources/example.php b/examples/php-api-client/resources/example.php new file mode 100644 index 00000000..f4946acb --- /dev/null +++ b/examples/php-api-client/resources/example.php @@ -0,0 +1,143 @@ + 50, + 'liveweight' => 450, + 'liveweight_gain' => 0.5 + ]); + + $summerSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 440, + 'liveweight_gain' => 0.3 + ]); + + $autumnSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 460, + 'liveweight_gain' => 0.4 + ]); + + $winterSeason = new PostBeefRequestBeefInnerClassesBullsGt1Autumn([ + 'head' => 50, + 'liveweight' => 450, + 'liveweight_gain' => 0.4 + ]); + + // Create cows class (greater than 2 years old) + $cowsGt2 = new PostBeefRequestBeefInnerClassesCowsGt2([ + 'spring' => $springSeason, + 'summer' => $summerSeason, + 'autumn' => $autumnSeason, + 'winter' => $winterSeason, + 'head_sold' => 25, + 'sale_weight' => 500 + ]); + + // Create classes object with cows + $classes = new PostBeefRequestBeefInnerClasses([ + 'cows_gt2' => $cowsGt2 + ]); + + // Create fertiliser object + $fertiliser = new PostBeefRequestBeefInnerFertiliser([ + 'single_superphosphate' => 5.0, + 'pasture_dryland' => 10.0, + 'pasture_irrigated' => 2.0, + 'crops_dryland' => 8.0, + 'crops_irrigated' => 1.0 + ]); + + // Create mineral supplementation object + $mineralSupplementation = new PostBeefRequestBeefInnerMineralSupplementation([ + 'mineral_block' => 2.0, + 'mineral_block_urea' => 0.3, + 'weaner_block' => 1.0, + 'weaner_block_urea' => 0.2, + 'dry_season_mix' => 1.5, + 'dry_season_mix_urea' => 0.25 + ]); + + // Create cows calving object + $cowsCalving = new PostBeefRequestBeefInnerCowsCalving([ + 'spring' => 0.2, + 'summer' => 0.1, + 'autumn' => 0.5, + 'winter' => 0.2 + ]); + + // Create beef inner object + $beefInner = new PostBeefRequestBeefInner([ + 'id' => 'beef_cattle_001', + 'classes' => $classes, + 'limestone' => 10.0, + 'limestone_fraction' => 0.8, + 'fertiliser' => $fertiliser, + 'diesel' => 1000, + 'petrol' => 200, + 'lpg' => 100, + 'mineral_supplementation' => $mineralSupplementation, + 'electricity_source' => 'State Grid', + 'electricity_renewable' => 0.2, + 'electricity_use' => 5000, + 'grain_feed' => 10.0, + 'hay_feed' => 5.0, + 'cottonseed_feed' => 2.0, + 'herbicide' => 50.0, + 'herbicide_other' => 20.0, + 'cows_calving' => $cowsCalving + ]); + + // Create main request object + $request = new PostBeefRequest([ + 'state' => 'qld', + 'north_of_tropic_of_capricorn' => true, + 'rainfall_above600' => true, + 'beef' => [$beefInner], + 'burning' => [], + 'vegetation' => [] + ]); + + // Configure API + $config = Configuration::getDefaultConfiguration(); + $config->setHost('https://emissionscalculator-mtls.staging.aiaapi.com/calculator/3.0.0'); + $config->setCertFile(__DIR__ . '/cert.pem'); + $config->setKeyFile(__DIR__ . '/key.pem'); + + // Initialize API + $api = new GAFApi(new Client(), $config); + + echo "Calling beef API...\n"; + echo "================================\n"; + + // Make the API call + $result = $api->postBeef($request); + + // Print the result + echo "Success! API call completed.\n\n"; + echo "Response:\n"; + print_r($result); + + echo "\n================================\n"; + echo "API call complete!\n"; + +} catch (Exception $e) { + echo "Error: " . $e->getMessage() . "\n"; + echo "File: " . $e->getFile() . "\n"; + echo "Line: " . $e->getLine() . "\n"; +} \ No newline at end of file diff --git a/examples/php-api-client/resources/run_test.sh b/examples/php-api-client/resources/run_test.sh new file mode 100755 index 00000000..cb1cecc6 --- /dev/null +++ b/examples/php-api-client/resources/run_test.sh @@ -0,0 +1 @@ +php ./example.php \ No newline at end of file diff --git a/examples/php-api-client/resources/setup_local.sh b/examples/php-api-client/resources/setup_local.sh new file mode 100755 index 00000000..03105477 --- /dev/null +++ b/examples/php-api-client/resources/setup_local.sh @@ -0,0 +1 @@ +composer install \ No newline at end of file diff --git a/examples/python-api-client/README.md b/examples/python-api-client/README.md new file mode 100644 index 00000000..a2531a2b --- /dev/null +++ b/examples/python-api-client/README.md @@ -0,0 +1,32 @@ +# Example Python API client for the AIA Carbon Calculators API + +This example shows how to call the REST API available at https://emissionscalculator-mtls.production.aiaapi.com/calculator/3.0.0 using a simple Python script. + +## Running the example + +You can execute a simple request to the `beef` endpoint using the example provided. You just need to update the parameters `cert_file="cert.pem"` and `key_file="key.pem"` in [test_pai.py](./api-client/test_api.py) so they point to your client certificate and key files. This allows the client to authenticate with the endpoint via mTLS. Once that has been done you just need to run: + +``` +cd api-client +setup_local.sh +run_test.sh +``` + +## Code generation + +The Python API client has been generated using the [openapi-generator-cli](https://www.npmjs.com/package/@openapitools/openapi-generator-cli) tool. The generation can be reproduced with a script like: + +``` +API_CLIENT_DIR=api-client +API_VERSION=3.0.0 +rm -rf $API_CLIENT_DIR + +npm -g install @openapitools/openapi-generator-cli +openapi-generator-cli generate \ + -i https://d2awla29kxgk7i.cloudfront.net/api/$API_VERSION/openapi.json \ + -g python \ + -o $API_CLIENT_DIR \ + --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false +``` + +For now, the Python generator does not support all the configuration needed for an mTLS connection out of the box. Several fixes have been applied to the generated code in the `api-client` folder to let this work end to end. Once this [PR](https://github.com/OpenAPITools/openapi-generator/pull/22229) has been merged and released, it will be possible to make requests via mTLS without any code changes to the generated PHP client code needed. diff --git a/examples/python-api-client/api-client/.github/workflows/python.yml b/examples/python-api-client/api-client/.github/workflows/python.yml new file mode 100644 index 00000000..02a097eb --- /dev/null +++ b/examples/python-api-client/api-client/.github/workflows/python.yml @@ -0,0 +1,34 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: openapi_client Python package + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r test-requirements.txt + - name: Test with pytest + run: | + pytest --cov=openapi_client diff --git a/examples/python-api-client/api-client/.gitignore b/examples/python-api-client/api-client/.gitignore new file mode 100644 index 00000000..43995bd4 --- /dev/null +++ b/examples/python-api-client/api-client/.gitignore @@ -0,0 +1,66 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/examples/python-api-client/api-client/.gitlab-ci.yml b/examples/python-api-client/api-client/.gitlab-ci.yml new file mode 100644 index 00000000..6b9641eb --- /dev/null +++ b/examples/python-api-client/api-client/.gitlab-ci.yml @@ -0,0 +1,31 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.gitlab.com/ee/ci/README.html +# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml + +stages: + - test + +.pytest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=openapi_client + +pytest-3.9: + extends: .pytest + image: python:3.9-alpine +pytest-3.10: + extends: .pytest + image: python:3.10-alpine +pytest-3.11: + extends: .pytest + image: python:3.11-alpine +pytest-3.12: + extends: .pytest + image: python:3.12-alpine +pytest-3.13: + extends: .pytest + image: python:3.13-alpine diff --git a/examples/python-api-client/api-client/.openapi-generator-ignore b/examples/python-api-client/api-client/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/examples/python-api-client/api-client/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/examples/python-api-client/api-client/.openapi-generator/FILES b/examples/python-api-client/api-client/.openapi-generator/FILES new file mode 100644 index 00000000..75994241 --- /dev/null +++ b/examples/python-api-client/api-client/.openapi-generator/FILES @@ -0,0 +1,314 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +git_push.sh +openapi_client/__init__.py +openapi_client/api/__init__.py +openapi_client/api/gaf_api.py +openapi_client/api_client.py +openapi_client/api_response.py +openapi_client/configuration.py +openapi_client/exceptions.py +openapi_client/models/__init__.py +openapi_client/models/post_aquaculture200_response.py +openapi_client/models/post_aquaculture200_response_carbon_sequestration.py +openapi_client/models/post_aquaculture200_response_intensities.py +openapi_client/models/post_aquaculture200_response_intermediate_inner.py +openapi_client/models/post_aquaculture200_response_intermediate_inner_carbon_sequestration.py +openapi_client/models/post_aquaculture200_response_net.py +openapi_client/models/post_aquaculture200_response_purchased_offsets.py +openapi_client/models/post_aquaculture200_response_scope1.py +openapi_client/models/post_aquaculture200_response_scope2.py +openapi_client/models/post_aquaculture200_response_scope3.py +openapi_client/models/post_aquaculture_request.py +openapi_client/models/post_aquaculture_request_enterprises_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_bait_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_custom_bait_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_fluid_waste_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_fuel.py +openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_inbound_freight_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_refrigerants_inner.py +openapi_client/models/post_aquaculture_request_enterprises_inner_solid_waste.py +openapi_client/models/post_beef200_response.py +openapi_client/models/post_beef200_response_intermediate_inner.py +openapi_client/models/post_beef200_response_intermediate_inner_intensities.py +openapi_client/models/post_beef200_response_net.py +openapi_client/models/post_beef200_response_scope1.py +openapi_client/models/post_beef200_response_scope3.py +openapi_client/models/post_beef_request.py +openapi_client/models/post_beef_request_beef_inner.py +openapi_client/models/post_beef_request_beef_inner_classes.py +openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1.py +openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_autumn.py +openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner.py +openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2.py +openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1.py +openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2.py +openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2.py +openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2_traded.py +openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1.py +openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1_traded.py +openapi_client/models/post_beef_request_beef_inner_cows_calving.py +openapi_client/models/post_beef_request_beef_inner_fertiliser.py +openapi_client/models/post_beef_request_beef_inner_fertiliser_other_fertilisers_inner.py +openapi_client/models/post_beef_request_beef_inner_mineral_supplementation.py +openapi_client/models/post_beef_request_burning_inner.py +openapi_client/models/post_beef_request_burning_inner_burning.py +openapi_client/models/post_beef_request_vegetation_inner.py +openapi_client/models/post_beef_request_vegetation_inner_vegetation.py +openapi_client/models/post_buffalo200_response.py +openapi_client/models/post_buffalo200_response_intensities.py +openapi_client/models/post_buffalo200_response_intermediate_inner.py +openapi_client/models/post_buffalo200_response_net.py +openapi_client/models/post_buffalo200_response_scope1.py +openapi_client/models/post_buffalo200_response_scope3.py +openapi_client/models/post_buffalo_request.py +openapi_client/models/post_buffalo_request_buffalos_inner.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_autumn.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_calfs.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_cows.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_steers.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_bulls.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_calfs.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_cows.py +openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_steers.py +openapi_client/models/post_buffalo_request_buffalos_inner_cows_calving.py +openapi_client/models/post_buffalo_request_buffalos_inner_seasonal_calving.py +openapi_client/models/post_buffalo_request_vegetation_inner.py +openapi_client/models/post_cotton200_response.py +openapi_client/models/post_cotton200_response_intermediate_inner.py +openapi_client/models/post_cotton200_response_intermediate_inner_intensities.py +openapi_client/models/post_cotton200_response_net.py +openapi_client/models/post_cotton200_response_scope1.py +openapi_client/models/post_cotton200_response_scope3.py +openapi_client/models/post_cotton_request.py +openapi_client/models/post_cotton_request_crops_inner.py +openapi_client/models/post_cotton_request_vegetation_inner.py +openapi_client/models/post_dairy200_response.py +openapi_client/models/post_dairy200_response_intensities.py +openapi_client/models/post_dairy200_response_intermediate_inner.py +openapi_client/models/post_dairy200_response_net.py +openapi_client/models/post_dairy200_response_scope1.py +openapi_client/models/post_dairy200_response_scope3.py +openapi_client/models/post_dairy_request.py +openapi_client/models/post_dairy_request_dairy_inner.py +openapi_client/models/post_dairy_request_dairy_inner_areas.py +openapi_client/models/post_dairy_request_dairy_inner_classes.py +openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_gt1.py +openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_lt1.py +openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_gt1.py +openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_lt1.py +openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows.py +openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows_autumn.py +openapi_client/models/post_dairy_request_dairy_inner_manure_management_milking_cows.py +openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser.py +openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser_autumn.py +openapi_client/models/post_dairy_request_vegetation_inner.py +openapi_client/models/post_deer200_response.py +openapi_client/models/post_deer200_response_intensities.py +openapi_client/models/post_deer200_response_intermediate_inner.py +openapi_client/models/post_deer200_response_net.py +openapi_client/models/post_deer_request.py +openapi_client/models/post_deer_request_deers_inner.py +openapi_client/models/post_deer_request_deers_inner_classes.py +openapi_client/models/post_deer_request_deers_inner_classes_breeding_does.py +openapi_client/models/post_deer_request_deers_inner_classes_bucks.py +openapi_client/models/post_deer_request_deers_inner_classes_fawn.py +openapi_client/models/post_deer_request_deers_inner_classes_other_does.py +openapi_client/models/post_deer_request_deers_inner_classes_trade_bucks.py +openapi_client/models/post_deer_request_deers_inner_classes_trade_does.py +openapi_client/models/post_deer_request_deers_inner_classes_trade_fawn.py +openapi_client/models/post_deer_request_deers_inner_classes_trade_other_does.py +openapi_client/models/post_deer_request_deers_inner_does_fawning.py +openapi_client/models/post_deer_request_deers_inner_seasonal_fawning.py +openapi_client/models/post_deer_request_vegetation_inner.py +openapi_client/models/post_feedlot200_response.py +openapi_client/models/post_feedlot200_response_intermediate_inner.py +openapi_client/models/post_feedlot200_response_intermediate_inner_intensities.py +openapi_client/models/post_feedlot200_response_intermediate_inner_net.py +openapi_client/models/post_feedlot200_response_scope1.py +openapi_client/models/post_feedlot200_response_scope3.py +openapi_client/models/post_feedlot_request.py +openapi_client/models/post_feedlot_request_feedlots_inner.py +openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner.py +openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner_stays_inner.py +openapi_client/models/post_feedlot_request_feedlots_inner_purchases.py +openapi_client/models/post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner.py +openapi_client/models/post_feedlot_request_feedlots_inner_sales.py +openapi_client/models/post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner.py +openapi_client/models/post_feedlot_request_vegetation_inner.py +openapi_client/models/post_goat200_response.py +openapi_client/models/post_goat200_response_intensities.py +openapi_client/models/post_goat200_response_intermediate_inner.py +openapi_client/models/post_goat200_response_net.py +openapi_client/models/post_goat_request.py +openapi_client/models/post_goat_request_goats_inner.py +openapi_client/models/post_goat_request_goats_inner_classes.py +openapi_client/models/post_goat_request_goats_inner_classes_breeding_does_nannies.py +openapi_client/models/post_goat_request_goats_inner_classes_bucks_billy.py +openapi_client/models/post_goat_request_goats_inner_classes_kids.py +openapi_client/models/post_goat_request_goats_inner_classes_maiden_breeding_does_nannies.py +openapi_client/models/post_goat_request_goats_inner_classes_other_does_culled_females.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_breeding_does_nannies.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_bucks.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_does.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_kids.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_other_does_culled_females.py +openapi_client/models/post_goat_request_goats_inner_classes_trade_wethers.py +openapi_client/models/post_goat_request_goats_inner_classes_wethers.py +openapi_client/models/post_goat_request_vegetation_inner.py +openapi_client/models/post_grains200_response.py +openapi_client/models/post_grains200_response_intermediate_inner.py +openapi_client/models/post_grains200_response_intermediate_inner_intensities_with_sequestration.py +openapi_client/models/post_grains_request.py +openapi_client/models/post_grains_request_crops_inner.py +openapi_client/models/post_horticulture200_response.py +openapi_client/models/post_horticulture200_response_intermediate_inner.py +openapi_client/models/post_horticulture200_response_intermediate_inner_intensities_with_sequestration.py +openapi_client/models/post_horticulture200_response_scope1.py +openapi_client/models/post_horticulture_request.py +openapi_client/models/post_horticulture_request_crops_inner.py +openapi_client/models/post_horticulture_request_crops_inner_refrigerants_inner.py +openapi_client/models/post_pork200_response.py +openapi_client/models/post_pork200_response_intensities.py +openapi_client/models/post_pork200_response_intermediate_inner.py +openapi_client/models/post_pork200_response_net.py +openapi_client/models/post_pork200_response_scope1.py +openapi_client/models/post_pork200_response_scope3.py +openapi_client/models/post_pork_request.py +openapi_client/models/post_pork_request_pork_inner.py +openapi_client/models/post_pork_request_pork_inner_classes.py +openapi_client/models/post_pork_request_pork_inner_classes_boars.py +openapi_client/models/post_pork_request_pork_inner_classes_gilts.py +openapi_client/models/post_pork_request_pork_inner_classes_growers.py +openapi_client/models/post_pork_request_pork_inner_classes_slaughter_pigs.py +openapi_client/models/post_pork_request_pork_inner_classes_sows.py +openapi_client/models/post_pork_request_pork_inner_classes_sows_manure.py +openapi_client/models/post_pork_request_pork_inner_classes_sows_manure_spring.py +openapi_client/models/post_pork_request_pork_inner_classes_suckers.py +openapi_client/models/post_pork_request_pork_inner_classes_weaners.py +openapi_client/models/post_pork_request_pork_inner_feed_products_inner.py +openapi_client/models/post_pork_request_pork_inner_feed_products_inner_ingredients.py +openapi_client/models/post_pork_request_vegetation_inner.py +openapi_client/models/post_poultry200_response.py +openapi_client/models/post_poultry200_response_intensities.py +openapi_client/models/post_poultry200_response_intermediate_broilers_inner.py +openapi_client/models/post_poultry200_response_intermediate_broilers_inner_intensities.py +openapi_client/models/post_poultry200_response_intermediate_layers_inner.py +openapi_client/models/post_poultry200_response_intermediate_layers_inner_intensities.py +openapi_client/models/post_poultry200_response_net.py +openapi_client/models/post_poultry200_response_scope1.py +openapi_client/models/post_poultry200_response_scope3.py +openapi_client/models/post_poultry_request.py +openapi_client/models/post_poultry_request_broilers_inner.py +openapi_client/models/post_poultry_request_broilers_inner_groups_inner.py +openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner.py +openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients.py +openapi_client/models/post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers.py +openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_growers_purchases.py +openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_layers_purchases.py +openapi_client/models/post_poultry_request_broilers_inner_meat_other_purchases.py +openapi_client/models/post_poultry_request_broilers_inner_sales_inner.py +openapi_client/models/post_poultry_request_layers_inner.py +openapi_client/models/post_poultry_request_layers_inner_layers.py +openapi_client/models/post_poultry_request_layers_inner_layers_egg_sale.py +openapi_client/models/post_poultry_request_layers_inner_layers_purchases.py +openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers.py +openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers_egg_sale.py +openapi_client/models/post_poultry_request_vegetation_inner.py +openapi_client/models/post_processing200_response.py +openapi_client/models/post_processing200_response_intensities_inner.py +openapi_client/models/post_processing200_response_intermediate_inner.py +openapi_client/models/post_processing200_response_net.py +openapi_client/models/post_processing200_response_scope1.py +openapi_client/models/post_processing200_response_scope3.py +openapi_client/models/post_processing_request.py +openapi_client/models/post_processing_request_products_inner.py +openapi_client/models/post_processing_request_products_inner_product.py +openapi_client/models/post_rice200_response.py +openapi_client/models/post_rice200_response_intensities.py +openapi_client/models/post_rice200_response_intermediate_inner.py +openapi_client/models/post_rice200_response_intermediate_inner_intensities.py +openapi_client/models/post_rice200_response_scope1.py +openapi_client/models/post_rice_request.py +openapi_client/models/post_rice_request_crops_inner.py +openapi_client/models/post_sheep200_response.py +openapi_client/models/post_sheep200_response_intermediate_inner.py +openapi_client/models/post_sheep200_response_intermediate_inner_intensities.py +openapi_client/models/post_sheep200_response_net.py +openapi_client/models/post_sheep_request.py +openapi_client/models/post_sheep_request_sheep_inner.py +openapi_client/models/post_sheep_request_sheep_inner_classes.py +openapi_client/models/post_sheep_request_sheep_inner_classes_rams.py +openapi_client/models/post_sheep_request_sheep_inner_classes_rams_autumn.py +openapi_client/models/post_sheep_request_sheep_inner_classes_trade_ewes.py +openapi_client/models/post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets.py +openapi_client/models/post_sheep_request_sheep_inner_ewes_lambing.py +openapi_client/models/post_sheep_request_sheep_inner_seasonal_lambing.py +openapi_client/models/post_sheep_request_vegetation_inner.py +openapi_client/models/post_sheepbeef200_response.py +openapi_client/models/post_sheepbeef200_response_intensities.py +openapi_client/models/post_sheepbeef200_response_intermediate.py +openapi_client/models/post_sheepbeef200_response_intermediate_beef.py +openapi_client/models/post_sheepbeef200_response_intermediate_sheep.py +openapi_client/models/post_sheepbeef200_response_net.py +openapi_client/models/post_sheepbeef_request.py +openapi_client/models/post_sheepbeef_request_vegetation_inner.py +openapi_client/models/post_sugar200_response.py +openapi_client/models/post_sugar200_response_intermediate_inner.py +openapi_client/models/post_sugar200_response_intermediate_inner_intensities.py +openapi_client/models/post_sugar_request.py +openapi_client/models/post_sugar_request_crops_inner.py +openapi_client/models/post_vineyard200_response.py +openapi_client/models/post_vineyard200_response_intermediate_inner.py +openapi_client/models/post_vineyard200_response_intermediate_inner_intensities.py +openapi_client/models/post_vineyard200_response_net.py +openapi_client/models/post_vineyard200_response_scope1.py +openapi_client/models/post_vineyard200_response_scope3.py +openapi_client/models/post_vineyard_request.py +openapi_client/models/post_vineyard_request_vegetation_inner.py +openapi_client/models/post_vineyard_request_vineyards_inner.py +openapi_client/models/post_wildcatchfishery200_response.py +openapi_client/models/post_wildcatchfishery200_response_intensities.py +openapi_client/models/post_wildcatchfishery200_response_intermediate_inner.py +openapi_client/models/post_wildcatchfishery200_response_scope1.py +openapi_client/models/post_wildcatchfishery_request.py +openapi_client/models/post_wildcatchfishery_request_enterprises_inner.py +openapi_client/models/post_wildcatchfishery_request_enterprises_inner_bait_inner.py +openapi_client/models/post_wildseafisheries200_response.py +openapi_client/models/post_wildseafisheries200_response_intermediate_inner.py +openapi_client/models/post_wildseafisheries200_response_intermediate_inner_intensities.py +openapi_client/models/post_wildseafisheries200_response_scope1.py +openapi_client/models/post_wildseafisheries200_response_scope3.py +openapi_client/models/post_wildseafisheries_request.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner_bait_inner.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner_custombait_inner.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner_flights_inner.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner_refrigerants_inner.py +openapi_client/models/post_wildseafisheries_request_enterprises_inner_transports_inner.py +openapi_client/py.typed +openapi_client/rest.py +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +tox.ini diff --git a/examples/python-api-client/api-client/.openapi-generator/VERSION b/examples/python-api-client/api-client/.openapi-generator/VERSION new file mode 100644 index 00000000..e465da43 --- /dev/null +++ b/examples/python-api-client/api-client/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.14.0 diff --git a/examples/python-api-client/api-client/.travis.yml b/examples/python-api-client/api-client/.travis.yml new file mode 100644 index 00000000..a3e4200d --- /dev/null +++ b/examples/python-api-client/api-client/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + # uncomment the following if needed + #- "3.13-dev" # 3.13 development branch + #- "nightly" # nightly build +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +script: pytest --cov=openapi_client diff --git a/examples/python-api-client/api-client/README.md b/examples/python-api-client/api-client/README.md new file mode 100644 index 00000000..4b593d37 --- /dev/null +++ b/examples/python-api-client/api-client/README.md @@ -0,0 +1,416 @@ +# openapi-client +Emissions Calculators for various farming activities + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 3.0.0 +- Package version: 1.0.0 +- Generator version: 7.14.0 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen +For more information, please visit [https://aginnovationaustralia.com.au/contact-us/](https://aginnovationaustralia.com.au/contact-us/) + +## Requirements. + +Python 3.9+ + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) + +Then import the package: +```python +import openapi_client +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import openapi_client +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0 +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0" +) + + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.GAFApi(api_client) + post_aquaculture_request = openapi_client.PostAquacultureRequest() # PostAquacultureRequest | + + try: + # Perform aquaculture calculation + api_response = api_instance.post_aquaculture(post_aquaculture_request) + print("The response of GAFApi->post_aquaculture:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling GAFApi->post_aquaculture: %s\n" % e) + +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*GAFApi* | [**post_aquaculture**](docs/GAFApi.md#post_aquaculture) | **POST** /aquaculture | Perform aquaculture calculation +*GAFApi* | [**post_beef**](docs/GAFApi.md#post_beef) | **POST** /beef | Perform beef calculation +*GAFApi* | [**post_buffalo**](docs/GAFApi.md#post_buffalo) | **POST** /buffalo | Perform buffalo calculation +*GAFApi* | [**post_cotton**](docs/GAFApi.md#post_cotton) | **POST** /cotton | Perform cotton calculation +*GAFApi* | [**post_dairy**](docs/GAFApi.md#post_dairy) | **POST** /dairy | Perform dairy calculation +*GAFApi* | [**post_deer**](docs/GAFApi.md#post_deer) | **POST** /deer | Perform deer calculation +*GAFApi* | [**post_feedlot**](docs/GAFApi.md#post_feedlot) | **POST** /feedlot | Perform feedlot calculation +*GAFApi* | [**post_goat**](docs/GAFApi.md#post_goat) | **POST** /goat | Perform goat calculation +*GAFApi* | [**post_grains**](docs/GAFApi.md#post_grains) | **POST** /grains | Perform grains calculation +*GAFApi* | [**post_horticulture**](docs/GAFApi.md#post_horticulture) | **POST** /horticulture | Perform horticulture calculation +*GAFApi* | [**post_pork**](docs/GAFApi.md#post_pork) | **POST** /pork | Perform pork calculation +*GAFApi* | [**post_poultry**](docs/GAFApi.md#post_poultry) | **POST** /poultry | Perform poultry calculation +*GAFApi* | [**post_processing**](docs/GAFApi.md#post_processing) | **POST** /processing | Perform processing calculation +*GAFApi* | [**post_rice**](docs/GAFApi.md#post_rice) | **POST** /rice | Perform rice calculation +*GAFApi* | [**post_sheep**](docs/GAFApi.md#post_sheep) | **POST** /sheep | Perform sheep calculation +*GAFApi* | [**post_sheepbeef**](docs/GAFApi.md#post_sheepbeef) | **POST** /sheepbeef | Perform sheepbeef calculation +*GAFApi* | [**post_sugar**](docs/GAFApi.md#post_sugar) | **POST** /sugar | Perform sugar calculation +*GAFApi* | [**post_vineyard**](docs/GAFApi.md#post_vineyard) | **POST** /vineyard | Perform vineyard calculation +*GAFApi* | [**post_wildcatchfishery**](docs/GAFApi.md#post_wildcatchfishery) | **POST** /wildcatchfishery | Perform wildcatchfishery calculation +*GAFApi* | [**post_wildseafisheries**](docs/GAFApi.md#post_wildseafisheries) | **POST** /wildseafisheries | Perform wildseafisheries calculation + + +## Documentation For Models + + - [PostAquaculture200Response](docs/PostAquaculture200Response.md) + - [PostAquaculture200ResponseCarbonSequestration](docs/PostAquaculture200ResponseCarbonSequestration.md) + - [PostAquaculture200ResponseIntensities](docs/PostAquaculture200ResponseIntensities.md) + - [PostAquaculture200ResponseIntermediateInner](docs/PostAquaculture200ResponseIntermediateInner.md) + - [PostAquaculture200ResponseIntermediateInnerCarbonSequestration](docs/PostAquaculture200ResponseIntermediateInnerCarbonSequestration.md) + - [PostAquaculture200ResponseNet](docs/PostAquaculture200ResponseNet.md) + - [PostAquaculture200ResponsePurchasedOffsets](docs/PostAquaculture200ResponsePurchasedOffsets.md) + - [PostAquaculture200ResponseScope1](docs/PostAquaculture200ResponseScope1.md) + - [PostAquaculture200ResponseScope2](docs/PostAquaculture200ResponseScope2.md) + - [PostAquaculture200ResponseScope3](docs/PostAquaculture200ResponseScope3.md) + - [PostAquacultureRequest](docs/PostAquacultureRequest.md) + - [PostAquacultureRequestEnterprisesInner](docs/PostAquacultureRequestEnterprisesInner.md) + - [PostAquacultureRequestEnterprisesInnerBaitInner](docs/PostAquacultureRequestEnterprisesInnerBaitInner.md) + - [PostAquacultureRequestEnterprisesInnerCustomBaitInner](docs/PostAquacultureRequestEnterprisesInnerCustomBaitInner.md) + - [PostAquacultureRequestEnterprisesInnerFluidWasteInner](docs/PostAquacultureRequestEnterprisesInnerFluidWasteInner.md) + - [PostAquacultureRequestEnterprisesInnerFuel](docs/PostAquacultureRequestEnterprisesInnerFuel.md) + - [PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner](docs/PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.md) + - [PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner](docs/PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.md) + - [PostAquacultureRequestEnterprisesInnerInboundFreightInner](docs/PostAquacultureRequestEnterprisesInnerInboundFreightInner.md) + - [PostAquacultureRequestEnterprisesInnerRefrigerantsInner](docs/PostAquacultureRequestEnterprisesInnerRefrigerantsInner.md) + - [PostAquacultureRequestEnterprisesInnerSolidWaste](docs/PostAquacultureRequestEnterprisesInnerSolidWaste.md) + - [PostBeef200Response](docs/PostBeef200Response.md) + - [PostBeef200ResponseIntermediateInner](docs/PostBeef200ResponseIntermediateInner.md) + - [PostBeef200ResponseIntermediateInnerIntensities](docs/PostBeef200ResponseIntermediateInnerIntensities.md) + - [PostBeef200ResponseNet](docs/PostBeef200ResponseNet.md) + - [PostBeef200ResponseScope1](docs/PostBeef200ResponseScope1.md) + - [PostBeef200ResponseScope3](docs/PostBeef200ResponseScope3.md) + - [PostBeefRequest](docs/PostBeefRequest.md) + - [PostBeefRequestBeefInner](docs/PostBeefRequestBeefInner.md) + - [PostBeefRequestBeefInnerClasses](docs/PostBeefRequestBeefInnerClasses.md) + - [PostBeefRequestBeefInnerClassesBullsGt1](docs/PostBeefRequestBeefInnerClassesBullsGt1.md) + - [PostBeefRequestBeefInnerClassesBullsGt1Autumn](docs/PostBeefRequestBeefInnerClassesBullsGt1Autumn.md) + - [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner](docs/PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.md) + - [PostBeefRequestBeefInnerClassesBullsGt1Traded](docs/PostBeefRequestBeefInnerClassesBullsGt1Traded.md) + - [PostBeefRequestBeefInnerClassesCowsGt2](docs/PostBeefRequestBeefInnerClassesCowsGt2.md) + - [PostBeefRequestBeefInnerClassesCowsGt2Traded](docs/PostBeefRequestBeefInnerClassesCowsGt2Traded.md) + - [PostBeefRequestBeefInnerClassesHeifers1To2](docs/PostBeefRequestBeefInnerClassesHeifers1To2.md) + - [PostBeefRequestBeefInnerClassesHeifers1To2Traded](docs/PostBeefRequestBeefInnerClassesHeifers1To2Traded.md) + - [PostBeefRequestBeefInnerClassesHeifersGt2](docs/PostBeefRequestBeefInnerClassesHeifersGt2.md) + - [PostBeefRequestBeefInnerClassesHeifersGt2Traded](docs/PostBeefRequestBeefInnerClassesHeifersGt2Traded.md) + - [PostBeefRequestBeefInnerClassesHeifersLt1](docs/PostBeefRequestBeefInnerClassesHeifersLt1.md) + - [PostBeefRequestBeefInnerClassesHeifersLt1Traded](docs/PostBeefRequestBeefInnerClassesHeifersLt1Traded.md) + - [PostBeefRequestBeefInnerClassesSteers1To2](docs/PostBeefRequestBeefInnerClassesSteers1To2.md) + - [PostBeefRequestBeefInnerClassesSteers1To2Traded](docs/PostBeefRequestBeefInnerClassesSteers1To2Traded.md) + - [PostBeefRequestBeefInnerClassesSteersGt2](docs/PostBeefRequestBeefInnerClassesSteersGt2.md) + - [PostBeefRequestBeefInnerClassesSteersGt2Traded](docs/PostBeefRequestBeefInnerClassesSteersGt2Traded.md) + - [PostBeefRequestBeefInnerClassesSteersLt1](docs/PostBeefRequestBeefInnerClassesSteersLt1.md) + - [PostBeefRequestBeefInnerClassesSteersLt1Traded](docs/PostBeefRequestBeefInnerClassesSteersLt1Traded.md) + - [PostBeefRequestBeefInnerCowsCalving](docs/PostBeefRequestBeefInnerCowsCalving.md) + - [PostBeefRequestBeefInnerFertiliser](docs/PostBeefRequestBeefInnerFertiliser.md) + - [PostBeefRequestBeefInnerFertiliserOtherFertilisersInner](docs/PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.md) + - [PostBeefRequestBeefInnerMineralSupplementation](docs/PostBeefRequestBeefInnerMineralSupplementation.md) + - [PostBeefRequestBurningInner](docs/PostBeefRequestBurningInner.md) + - [PostBeefRequestBurningInnerBurning](docs/PostBeefRequestBurningInnerBurning.md) + - [PostBeefRequestVegetationInner](docs/PostBeefRequestVegetationInner.md) + - [PostBeefRequestVegetationInnerVegetation](docs/PostBeefRequestVegetationInnerVegetation.md) + - [PostBuffalo200Response](docs/PostBuffalo200Response.md) + - [PostBuffalo200ResponseIntensities](docs/PostBuffalo200ResponseIntensities.md) + - [PostBuffalo200ResponseIntermediateInner](docs/PostBuffalo200ResponseIntermediateInner.md) + - [PostBuffalo200ResponseNet](docs/PostBuffalo200ResponseNet.md) + - [PostBuffalo200ResponseScope1](docs/PostBuffalo200ResponseScope1.md) + - [PostBuffalo200ResponseScope3](docs/PostBuffalo200ResponseScope3.md) + - [PostBuffaloRequest](docs/PostBuffaloRequest.md) + - [PostBuffaloRequestBuffalosInner](docs/PostBuffaloRequestBuffalosInner.md) + - [PostBuffaloRequestBuffalosInnerClasses](docs/PostBuffaloRequestBuffalosInnerClasses.md) + - [PostBuffaloRequestBuffalosInnerClassesBulls](docs/PostBuffaloRequestBuffalosInnerClassesBulls.md) + - [PostBuffaloRequestBuffalosInnerClassesBullsAutumn](docs/PostBuffaloRequestBuffalosInnerClassesBullsAutumn.md) + - [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner](docs/PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.md) + - [PostBuffaloRequestBuffalosInnerClassesCalfs](docs/PostBuffaloRequestBuffalosInnerClassesCalfs.md) + - [PostBuffaloRequestBuffalosInnerClassesCows](docs/PostBuffaloRequestBuffalosInnerClassesCows.md) + - [PostBuffaloRequestBuffalosInnerClassesSteers](docs/PostBuffaloRequestBuffalosInnerClassesSteers.md) + - [PostBuffaloRequestBuffalosInnerClassesTradeBulls](docs/PostBuffaloRequestBuffalosInnerClassesTradeBulls.md) + - [PostBuffaloRequestBuffalosInnerClassesTradeCalfs](docs/PostBuffaloRequestBuffalosInnerClassesTradeCalfs.md) + - [PostBuffaloRequestBuffalosInnerClassesTradeCows](docs/PostBuffaloRequestBuffalosInnerClassesTradeCows.md) + - [PostBuffaloRequestBuffalosInnerClassesTradeSteers](docs/PostBuffaloRequestBuffalosInnerClassesTradeSteers.md) + - [PostBuffaloRequestBuffalosInnerCowsCalving](docs/PostBuffaloRequestBuffalosInnerCowsCalving.md) + - [PostBuffaloRequestBuffalosInnerSeasonalCalving](docs/PostBuffaloRequestBuffalosInnerSeasonalCalving.md) + - [PostBuffaloRequestVegetationInner](docs/PostBuffaloRequestVegetationInner.md) + - [PostCotton200Response](docs/PostCotton200Response.md) + - [PostCotton200ResponseIntermediateInner](docs/PostCotton200ResponseIntermediateInner.md) + - [PostCotton200ResponseIntermediateInnerIntensities](docs/PostCotton200ResponseIntermediateInnerIntensities.md) + - [PostCotton200ResponseNet](docs/PostCotton200ResponseNet.md) + - [PostCotton200ResponseScope1](docs/PostCotton200ResponseScope1.md) + - [PostCotton200ResponseScope3](docs/PostCotton200ResponseScope3.md) + - [PostCottonRequest](docs/PostCottonRequest.md) + - [PostCottonRequestCropsInner](docs/PostCottonRequestCropsInner.md) + - [PostCottonRequestVegetationInner](docs/PostCottonRequestVegetationInner.md) + - [PostDairy200Response](docs/PostDairy200Response.md) + - [PostDairy200ResponseIntensities](docs/PostDairy200ResponseIntensities.md) + - [PostDairy200ResponseIntermediateInner](docs/PostDairy200ResponseIntermediateInner.md) + - [PostDairy200ResponseNet](docs/PostDairy200ResponseNet.md) + - [PostDairy200ResponseScope1](docs/PostDairy200ResponseScope1.md) + - [PostDairy200ResponseScope3](docs/PostDairy200ResponseScope3.md) + - [PostDairyRequest](docs/PostDairyRequest.md) + - [PostDairyRequestDairyInner](docs/PostDairyRequestDairyInner.md) + - [PostDairyRequestDairyInnerAreas](docs/PostDairyRequestDairyInnerAreas.md) + - [PostDairyRequestDairyInnerClasses](docs/PostDairyRequestDairyInnerClasses.md) + - [PostDairyRequestDairyInnerClassesDairyBullsGt1](docs/PostDairyRequestDairyInnerClassesDairyBullsGt1.md) + - [PostDairyRequestDairyInnerClassesDairyBullsLt1](docs/PostDairyRequestDairyInnerClassesDairyBullsLt1.md) + - [PostDairyRequestDairyInnerClassesHeifersGt1](docs/PostDairyRequestDairyInnerClassesHeifersGt1.md) + - [PostDairyRequestDairyInnerClassesHeifersLt1](docs/PostDairyRequestDairyInnerClassesHeifersLt1.md) + - [PostDairyRequestDairyInnerClassesMilkingCows](docs/PostDairyRequestDairyInnerClassesMilkingCows.md) + - [PostDairyRequestDairyInnerClassesMilkingCowsAutumn](docs/PostDairyRequestDairyInnerClassesMilkingCowsAutumn.md) + - [PostDairyRequestDairyInnerManureManagementMilkingCows](docs/PostDairyRequestDairyInnerManureManagementMilkingCows.md) + - [PostDairyRequestDairyInnerSeasonalFertiliser](docs/PostDairyRequestDairyInnerSeasonalFertiliser.md) + - [PostDairyRequestDairyInnerSeasonalFertiliserAutumn](docs/PostDairyRequestDairyInnerSeasonalFertiliserAutumn.md) + - [PostDairyRequestVegetationInner](docs/PostDairyRequestVegetationInner.md) + - [PostDeer200Response](docs/PostDeer200Response.md) + - [PostDeer200ResponseIntensities](docs/PostDeer200ResponseIntensities.md) + - [PostDeer200ResponseIntermediateInner](docs/PostDeer200ResponseIntermediateInner.md) + - [PostDeer200ResponseNet](docs/PostDeer200ResponseNet.md) + - [PostDeerRequest](docs/PostDeerRequest.md) + - [PostDeerRequestDeersInner](docs/PostDeerRequestDeersInner.md) + - [PostDeerRequestDeersInnerClasses](docs/PostDeerRequestDeersInnerClasses.md) + - [PostDeerRequestDeersInnerClassesBreedingDoes](docs/PostDeerRequestDeersInnerClassesBreedingDoes.md) + - [PostDeerRequestDeersInnerClassesBucks](docs/PostDeerRequestDeersInnerClassesBucks.md) + - [PostDeerRequestDeersInnerClassesFawn](docs/PostDeerRequestDeersInnerClassesFawn.md) + - [PostDeerRequestDeersInnerClassesOtherDoes](docs/PostDeerRequestDeersInnerClassesOtherDoes.md) + - [PostDeerRequestDeersInnerClassesTradeBucks](docs/PostDeerRequestDeersInnerClassesTradeBucks.md) + - [PostDeerRequestDeersInnerClassesTradeDoes](docs/PostDeerRequestDeersInnerClassesTradeDoes.md) + - [PostDeerRequestDeersInnerClassesTradeFawn](docs/PostDeerRequestDeersInnerClassesTradeFawn.md) + - [PostDeerRequestDeersInnerClassesTradeOtherDoes](docs/PostDeerRequestDeersInnerClassesTradeOtherDoes.md) + - [PostDeerRequestDeersInnerDoesFawning](docs/PostDeerRequestDeersInnerDoesFawning.md) + - [PostDeerRequestDeersInnerSeasonalFawning](docs/PostDeerRequestDeersInnerSeasonalFawning.md) + - [PostDeerRequestVegetationInner](docs/PostDeerRequestVegetationInner.md) + - [PostFeedlot200Response](docs/PostFeedlot200Response.md) + - [PostFeedlot200ResponseIntermediateInner](docs/PostFeedlot200ResponseIntermediateInner.md) + - [PostFeedlot200ResponseIntermediateInnerIntensities](docs/PostFeedlot200ResponseIntermediateInnerIntensities.md) + - [PostFeedlot200ResponseIntermediateInnerNet](docs/PostFeedlot200ResponseIntermediateInnerNet.md) + - [PostFeedlot200ResponseScope1](docs/PostFeedlot200ResponseScope1.md) + - [PostFeedlot200ResponseScope3](docs/PostFeedlot200ResponseScope3.md) + - [PostFeedlotRequest](docs/PostFeedlotRequest.md) + - [PostFeedlotRequestFeedlotsInner](docs/PostFeedlotRequestFeedlotsInner.md) + - [PostFeedlotRequestFeedlotsInnerGroupsInner](docs/PostFeedlotRequestFeedlotsInnerGroupsInner.md) + - [PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner](docs/PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.md) + - [PostFeedlotRequestFeedlotsInnerPurchases](docs/PostFeedlotRequestFeedlotsInnerPurchases.md) + - [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner](docs/PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.md) + - [PostFeedlotRequestFeedlotsInnerSales](docs/PostFeedlotRequestFeedlotsInnerSales.md) + - [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner](docs/PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.md) + - [PostFeedlotRequestVegetationInner](docs/PostFeedlotRequestVegetationInner.md) + - [PostGoat200Response](docs/PostGoat200Response.md) + - [PostGoat200ResponseIntensities](docs/PostGoat200ResponseIntensities.md) + - [PostGoat200ResponseIntermediateInner](docs/PostGoat200ResponseIntermediateInner.md) + - [PostGoat200ResponseNet](docs/PostGoat200ResponseNet.md) + - [PostGoatRequest](docs/PostGoatRequest.md) + - [PostGoatRequestGoatsInner](docs/PostGoatRequestGoatsInner.md) + - [PostGoatRequestGoatsInnerClasses](docs/PostGoatRequestGoatsInnerClasses.md) + - [PostGoatRequestGoatsInnerClassesBreedingDoesNannies](docs/PostGoatRequestGoatsInnerClassesBreedingDoesNannies.md) + - [PostGoatRequestGoatsInnerClassesBucksBilly](docs/PostGoatRequestGoatsInnerClassesBucksBilly.md) + - [PostGoatRequestGoatsInnerClassesKids](docs/PostGoatRequestGoatsInnerClassesKids.md) + - [PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies](docs/PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.md) + - [PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales](docs/PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.md) + - [PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies](docs/PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.md) + - [PostGoatRequestGoatsInnerClassesTradeBucks](docs/PostGoatRequestGoatsInnerClassesTradeBucks.md) + - [PostGoatRequestGoatsInnerClassesTradeDoes](docs/PostGoatRequestGoatsInnerClassesTradeDoes.md) + - [PostGoatRequestGoatsInnerClassesTradeKids](docs/PostGoatRequestGoatsInnerClassesTradeKids.md) + - [PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies](docs/PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.md) + - [PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales](docs/PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.md) + - [PostGoatRequestGoatsInnerClassesTradeWethers](docs/PostGoatRequestGoatsInnerClassesTradeWethers.md) + - [PostGoatRequestGoatsInnerClassesWethers](docs/PostGoatRequestGoatsInnerClassesWethers.md) + - [PostGoatRequestVegetationInner](docs/PostGoatRequestVegetationInner.md) + - [PostGrains200Response](docs/PostGrains200Response.md) + - [PostGrains200ResponseIntermediateInner](docs/PostGrains200ResponseIntermediateInner.md) + - [PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration](docs/PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.md) + - [PostGrainsRequest](docs/PostGrainsRequest.md) + - [PostGrainsRequestCropsInner](docs/PostGrainsRequestCropsInner.md) + - [PostHorticulture200Response](docs/PostHorticulture200Response.md) + - [PostHorticulture200ResponseIntermediateInner](docs/PostHorticulture200ResponseIntermediateInner.md) + - [PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration](docs/PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.md) + - [PostHorticulture200ResponseScope1](docs/PostHorticulture200ResponseScope1.md) + - [PostHorticultureRequest](docs/PostHorticultureRequest.md) + - [PostHorticultureRequestCropsInner](docs/PostHorticultureRequestCropsInner.md) + - [PostHorticultureRequestCropsInnerRefrigerantsInner](docs/PostHorticultureRequestCropsInnerRefrigerantsInner.md) + - [PostPork200Response](docs/PostPork200Response.md) + - [PostPork200ResponseIntensities](docs/PostPork200ResponseIntensities.md) + - [PostPork200ResponseIntermediateInner](docs/PostPork200ResponseIntermediateInner.md) + - [PostPork200ResponseNet](docs/PostPork200ResponseNet.md) + - [PostPork200ResponseScope1](docs/PostPork200ResponseScope1.md) + - [PostPork200ResponseScope3](docs/PostPork200ResponseScope3.md) + - [PostPorkRequest](docs/PostPorkRequest.md) + - [PostPorkRequestPorkInner](docs/PostPorkRequestPorkInner.md) + - [PostPorkRequestPorkInnerClasses](docs/PostPorkRequestPorkInnerClasses.md) + - [PostPorkRequestPorkInnerClassesBoars](docs/PostPorkRequestPorkInnerClassesBoars.md) + - [PostPorkRequestPorkInnerClassesGilts](docs/PostPorkRequestPorkInnerClassesGilts.md) + - [PostPorkRequestPorkInnerClassesGrowers](docs/PostPorkRequestPorkInnerClassesGrowers.md) + - [PostPorkRequestPorkInnerClassesSlaughterPigs](docs/PostPorkRequestPorkInnerClassesSlaughterPigs.md) + - [PostPorkRequestPorkInnerClassesSows](docs/PostPorkRequestPorkInnerClassesSows.md) + - [PostPorkRequestPorkInnerClassesSowsManure](docs/PostPorkRequestPorkInnerClassesSowsManure.md) + - [PostPorkRequestPorkInnerClassesSowsManureSpring](docs/PostPorkRequestPorkInnerClassesSowsManureSpring.md) + - [PostPorkRequestPorkInnerClassesSuckers](docs/PostPorkRequestPorkInnerClassesSuckers.md) + - [PostPorkRequestPorkInnerClassesWeaners](docs/PostPorkRequestPorkInnerClassesWeaners.md) + - [PostPorkRequestPorkInnerFeedProductsInner](docs/PostPorkRequestPorkInnerFeedProductsInner.md) + - [PostPorkRequestPorkInnerFeedProductsInnerIngredients](docs/PostPorkRequestPorkInnerFeedProductsInnerIngredients.md) + - [PostPorkRequestVegetationInner](docs/PostPorkRequestVegetationInner.md) + - [PostPoultry200Response](docs/PostPoultry200Response.md) + - [PostPoultry200ResponseIntensities](docs/PostPoultry200ResponseIntensities.md) + - [PostPoultry200ResponseIntermediateBroilersInner](docs/PostPoultry200ResponseIntermediateBroilersInner.md) + - [PostPoultry200ResponseIntermediateBroilersInnerIntensities](docs/PostPoultry200ResponseIntermediateBroilersInnerIntensities.md) + - [PostPoultry200ResponseIntermediateLayersInner](docs/PostPoultry200ResponseIntermediateLayersInner.md) + - [PostPoultry200ResponseIntermediateLayersInnerIntensities](docs/PostPoultry200ResponseIntermediateLayersInnerIntensities.md) + - [PostPoultry200ResponseNet](docs/PostPoultry200ResponseNet.md) + - [PostPoultry200ResponseScope1](docs/PostPoultry200ResponseScope1.md) + - [PostPoultry200ResponseScope3](docs/PostPoultry200ResponseScope3.md) + - [PostPoultryRequest](docs/PostPoultryRequest.md) + - [PostPoultryRequestBroilersInner](docs/PostPoultryRequestBroilersInner.md) + - [PostPoultryRequestBroilersInnerGroupsInner](docs/PostPoultryRequestBroilersInnerGroupsInner.md) + - [PostPoultryRequestBroilersInnerGroupsInnerFeedInner](docs/PostPoultryRequestBroilersInnerGroupsInnerFeedInner.md) + - [PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients](docs/PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.md) + - [PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers](docs/PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.md) + - [PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases](docs/PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.md) + - [PostPoultryRequestBroilersInnerMeatChickenLayersPurchases](docs/PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.md) + - [PostPoultryRequestBroilersInnerMeatOtherPurchases](docs/PostPoultryRequestBroilersInnerMeatOtherPurchases.md) + - [PostPoultryRequestBroilersInnerSalesInner](docs/PostPoultryRequestBroilersInnerSalesInner.md) + - [PostPoultryRequestLayersInner](docs/PostPoultryRequestLayersInner.md) + - [PostPoultryRequestLayersInnerLayers](docs/PostPoultryRequestLayersInnerLayers.md) + - [PostPoultryRequestLayersInnerLayersEggSale](docs/PostPoultryRequestLayersInnerLayersEggSale.md) + - [PostPoultryRequestLayersInnerLayersPurchases](docs/PostPoultryRequestLayersInnerLayersPurchases.md) + - [PostPoultryRequestLayersInnerMeatChickenLayers](docs/PostPoultryRequestLayersInnerMeatChickenLayers.md) + - [PostPoultryRequestLayersInnerMeatChickenLayersEggSale](docs/PostPoultryRequestLayersInnerMeatChickenLayersEggSale.md) + - [PostPoultryRequestVegetationInner](docs/PostPoultryRequestVegetationInner.md) + - [PostProcessing200Response](docs/PostProcessing200Response.md) + - [PostProcessing200ResponseIntensitiesInner](docs/PostProcessing200ResponseIntensitiesInner.md) + - [PostProcessing200ResponseIntermediateInner](docs/PostProcessing200ResponseIntermediateInner.md) + - [PostProcessing200ResponseNet](docs/PostProcessing200ResponseNet.md) + - [PostProcessing200ResponseScope1](docs/PostProcessing200ResponseScope1.md) + - [PostProcessing200ResponseScope3](docs/PostProcessing200ResponseScope3.md) + - [PostProcessingRequest](docs/PostProcessingRequest.md) + - [PostProcessingRequestProductsInner](docs/PostProcessingRequestProductsInner.md) + - [PostProcessingRequestProductsInnerProduct](docs/PostProcessingRequestProductsInnerProduct.md) + - [PostRice200Response](docs/PostRice200Response.md) + - [PostRice200ResponseIntensities](docs/PostRice200ResponseIntensities.md) + - [PostRice200ResponseIntermediateInner](docs/PostRice200ResponseIntermediateInner.md) + - [PostRice200ResponseIntermediateInnerIntensities](docs/PostRice200ResponseIntermediateInnerIntensities.md) + - [PostRice200ResponseScope1](docs/PostRice200ResponseScope1.md) + - [PostRiceRequest](docs/PostRiceRequest.md) + - [PostRiceRequestCropsInner](docs/PostRiceRequestCropsInner.md) + - [PostSheep200Response](docs/PostSheep200Response.md) + - [PostSheep200ResponseIntermediateInner](docs/PostSheep200ResponseIntermediateInner.md) + - [PostSheep200ResponseIntermediateInnerIntensities](docs/PostSheep200ResponseIntermediateInnerIntensities.md) + - [PostSheep200ResponseNet](docs/PostSheep200ResponseNet.md) + - [PostSheepRequest](docs/PostSheepRequest.md) + - [PostSheepRequestSheepInner](docs/PostSheepRequestSheepInner.md) + - [PostSheepRequestSheepInnerClasses](docs/PostSheepRequestSheepInnerClasses.md) + - [PostSheepRequestSheepInnerClassesRams](docs/PostSheepRequestSheepInnerClassesRams.md) + - [PostSheepRequestSheepInnerClassesRamsAutumn](docs/PostSheepRequestSheepInnerClassesRamsAutumn.md) + - [PostSheepRequestSheepInnerClassesTradeEwes](docs/PostSheepRequestSheepInnerClassesTradeEwes.md) + - [PostSheepRequestSheepInnerClassesTradeLambsAndHoggets](docs/PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.md) + - [PostSheepRequestSheepInnerEwesLambing](docs/PostSheepRequestSheepInnerEwesLambing.md) + - [PostSheepRequestSheepInnerSeasonalLambing](docs/PostSheepRequestSheepInnerSeasonalLambing.md) + - [PostSheepRequestVegetationInner](docs/PostSheepRequestVegetationInner.md) + - [PostSheepbeef200Response](docs/PostSheepbeef200Response.md) + - [PostSheepbeef200ResponseIntensities](docs/PostSheepbeef200ResponseIntensities.md) + - [PostSheepbeef200ResponseIntermediate](docs/PostSheepbeef200ResponseIntermediate.md) + - [PostSheepbeef200ResponseIntermediateBeef](docs/PostSheepbeef200ResponseIntermediateBeef.md) + - [PostSheepbeef200ResponseIntermediateSheep](docs/PostSheepbeef200ResponseIntermediateSheep.md) + - [PostSheepbeef200ResponseNet](docs/PostSheepbeef200ResponseNet.md) + - [PostSheepbeefRequest](docs/PostSheepbeefRequest.md) + - [PostSheepbeefRequestVegetationInner](docs/PostSheepbeefRequestVegetationInner.md) + - [PostSugar200Response](docs/PostSugar200Response.md) + - [PostSugar200ResponseIntermediateInner](docs/PostSugar200ResponseIntermediateInner.md) + - [PostSugar200ResponseIntermediateInnerIntensities](docs/PostSugar200ResponseIntermediateInnerIntensities.md) + - [PostSugarRequest](docs/PostSugarRequest.md) + - [PostSugarRequestCropsInner](docs/PostSugarRequestCropsInner.md) + - [PostVineyard200Response](docs/PostVineyard200Response.md) + - [PostVineyard200ResponseIntermediateInner](docs/PostVineyard200ResponseIntermediateInner.md) + - [PostVineyard200ResponseIntermediateInnerIntensities](docs/PostVineyard200ResponseIntermediateInnerIntensities.md) + - [PostVineyard200ResponseNet](docs/PostVineyard200ResponseNet.md) + - [PostVineyard200ResponseScope1](docs/PostVineyard200ResponseScope1.md) + - [PostVineyard200ResponseScope3](docs/PostVineyard200ResponseScope3.md) + - [PostVineyardRequest](docs/PostVineyardRequest.md) + - [PostVineyardRequestVegetationInner](docs/PostVineyardRequestVegetationInner.md) + - [PostVineyardRequestVineyardsInner](docs/PostVineyardRequestVineyardsInner.md) + - [PostWildcatchfishery200Response](docs/PostWildcatchfishery200Response.md) + - [PostWildcatchfishery200ResponseIntensities](docs/PostWildcatchfishery200ResponseIntensities.md) + - [PostWildcatchfishery200ResponseIntermediateInner](docs/PostWildcatchfishery200ResponseIntermediateInner.md) + - [PostWildcatchfishery200ResponseScope1](docs/PostWildcatchfishery200ResponseScope1.md) + - [PostWildcatchfisheryRequest](docs/PostWildcatchfisheryRequest.md) + - [PostWildcatchfisheryRequestEnterprisesInner](docs/PostWildcatchfisheryRequestEnterprisesInner.md) + - [PostWildcatchfisheryRequestEnterprisesInnerBaitInner](docs/PostWildcatchfisheryRequestEnterprisesInnerBaitInner.md) + - [PostWildseafisheries200Response](docs/PostWildseafisheries200Response.md) + - [PostWildseafisheries200ResponseIntermediateInner](docs/PostWildseafisheries200ResponseIntermediateInner.md) + - [PostWildseafisheries200ResponseIntermediateInnerIntensities](docs/PostWildseafisheries200ResponseIntermediateInnerIntensities.md) + - [PostWildseafisheries200ResponseScope1](docs/PostWildseafisheries200ResponseScope1.md) + - [PostWildseafisheries200ResponseScope3](docs/PostWildseafisheries200ResponseScope3.md) + - [PostWildseafisheriesRequest](docs/PostWildseafisheriesRequest.md) + - [PostWildseafisheriesRequestEnterprisesInner](docs/PostWildseafisheriesRequestEnterprisesInner.md) + - [PostWildseafisheriesRequestEnterprisesInnerBaitInner](docs/PostWildseafisheriesRequestEnterprisesInnerBaitInner.md) + - [PostWildseafisheriesRequestEnterprisesInnerCustombaitInner](docs/PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.md) + - [PostWildseafisheriesRequestEnterprisesInnerFlightsInner](docs/PostWildseafisheriesRequestEnterprisesInnerFlightsInner.md) + - [PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner](docs/PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.md) + - [PostWildseafisheriesRequestEnterprisesInnerTransportsInner](docs/PostWildseafisheriesRequestEnterprisesInnerTransportsInner.md) + + + +## Documentation For Authorization + +Endpoints do not require authorization. + + +## Author + +contact@aginnovationaustralia.com.au + + diff --git a/examples/python-api-client/api-client/git_push.sh b/examples/python-api-client/api-client/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/examples/python-api-client/api-client/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/examples/python-api-client/api-client/openapi_client/__init__.py b/examples/python-api-client/api-client/openapi_client/__init__.py new file mode 100644 index 00000000..f2a5cbb1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/__init__.py @@ -0,0 +1,630 @@ +# coding: utf-8 + +# flake8: noqa + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# Define package exports +__all__ = [ + "GAFApi", + "ApiResponse", + "ApiClient", + "Configuration", + "OpenApiException", + "ApiTypeError", + "ApiValueError", + "ApiKeyError", + "ApiAttributeError", + "ApiException", + "PostAquaculture200Response", + "PostAquaculture200ResponseCarbonSequestration", + "PostAquaculture200ResponseIntensities", + "PostAquaculture200ResponseIntermediateInner", + "PostAquaculture200ResponseIntermediateInnerCarbonSequestration", + "PostAquaculture200ResponseNet", + "PostAquaculture200ResponsePurchasedOffsets", + "PostAquaculture200ResponseScope1", + "PostAquaculture200ResponseScope2", + "PostAquaculture200ResponseScope3", + "PostAquacultureRequest", + "PostAquacultureRequestEnterprisesInner", + "PostAquacultureRequestEnterprisesInnerBaitInner", + "PostAquacultureRequestEnterprisesInnerCustomBaitInner", + "PostAquacultureRequestEnterprisesInnerFluidWasteInner", + "PostAquacultureRequestEnterprisesInnerFuel", + "PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner", + "PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner", + "PostAquacultureRequestEnterprisesInnerInboundFreightInner", + "PostAquacultureRequestEnterprisesInnerRefrigerantsInner", + "PostAquacultureRequestEnterprisesInnerSolidWaste", + "PostBeef200Response", + "PostBeef200ResponseIntermediateInner", + "PostBeef200ResponseIntermediateInnerIntensities", + "PostBeef200ResponseNet", + "PostBeef200ResponseScope1", + "PostBeef200ResponseScope3", + "PostBeefRequest", + "PostBeefRequestBeefInner", + "PostBeefRequestBeefInnerClasses", + "PostBeefRequestBeefInnerClassesBullsGt1", + "PostBeefRequestBeefInnerClassesBullsGt1Autumn", + "PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner", + "PostBeefRequestBeefInnerClassesBullsGt1Traded", + "PostBeefRequestBeefInnerClassesCowsGt2", + "PostBeefRequestBeefInnerClassesCowsGt2Traded", + "PostBeefRequestBeefInnerClassesHeifers1To2", + "PostBeefRequestBeefInnerClassesHeifers1To2Traded", + "PostBeefRequestBeefInnerClassesHeifersGt2", + "PostBeefRequestBeefInnerClassesHeifersGt2Traded", + "PostBeefRequestBeefInnerClassesHeifersLt1", + "PostBeefRequestBeefInnerClassesHeifersLt1Traded", + "PostBeefRequestBeefInnerClassesSteers1To2", + "PostBeefRequestBeefInnerClassesSteers1To2Traded", + "PostBeefRequestBeefInnerClassesSteersGt2", + "PostBeefRequestBeefInnerClassesSteersGt2Traded", + "PostBeefRequestBeefInnerClassesSteersLt1", + "PostBeefRequestBeefInnerClassesSteersLt1Traded", + "PostBeefRequestBeefInnerCowsCalving", + "PostBeefRequestBeefInnerFertiliser", + "PostBeefRequestBeefInnerFertiliserOtherFertilisersInner", + "PostBeefRequestBeefInnerMineralSupplementation", + "PostBeefRequestBurningInner", + "PostBeefRequestBurningInnerBurning", + "PostBeefRequestVegetationInner", + "PostBeefRequestVegetationInnerVegetation", + "PostBuffalo200Response", + "PostBuffalo200ResponseIntensities", + "PostBuffalo200ResponseIntermediateInner", + "PostBuffalo200ResponseNet", + "PostBuffalo200ResponseScope1", + "PostBuffalo200ResponseScope3", + "PostBuffaloRequest", + "PostBuffaloRequestBuffalosInner", + "PostBuffaloRequestBuffalosInnerClasses", + "PostBuffaloRequestBuffalosInnerClassesBulls", + "PostBuffaloRequestBuffalosInnerClassesBullsAutumn", + "PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner", + "PostBuffaloRequestBuffalosInnerClassesCalfs", + "PostBuffaloRequestBuffalosInnerClassesCows", + "PostBuffaloRequestBuffalosInnerClassesSteers", + "PostBuffaloRequestBuffalosInnerClassesTradeBulls", + "PostBuffaloRequestBuffalosInnerClassesTradeCalfs", + "PostBuffaloRequestBuffalosInnerClassesTradeCows", + "PostBuffaloRequestBuffalosInnerClassesTradeSteers", + "PostBuffaloRequestBuffalosInnerCowsCalving", + "PostBuffaloRequestBuffalosInnerSeasonalCalving", + "PostBuffaloRequestVegetationInner", + "PostCotton200Response", + "PostCotton200ResponseIntermediateInner", + "PostCotton200ResponseIntermediateInnerIntensities", + "PostCotton200ResponseNet", + "PostCotton200ResponseScope1", + "PostCotton200ResponseScope3", + "PostCottonRequest", + "PostCottonRequestCropsInner", + "PostCottonRequestVegetationInner", + "PostDairy200Response", + "PostDairy200ResponseIntensities", + "PostDairy200ResponseIntermediateInner", + "PostDairy200ResponseNet", + "PostDairy200ResponseScope1", + "PostDairy200ResponseScope3", + "PostDairyRequest", + "PostDairyRequestDairyInner", + "PostDairyRequestDairyInnerAreas", + "PostDairyRequestDairyInnerClasses", + "PostDairyRequestDairyInnerClassesDairyBullsGt1", + "PostDairyRequestDairyInnerClassesDairyBullsLt1", + "PostDairyRequestDairyInnerClassesHeifersGt1", + "PostDairyRequestDairyInnerClassesHeifersLt1", + "PostDairyRequestDairyInnerClassesMilkingCows", + "PostDairyRequestDairyInnerClassesMilkingCowsAutumn", + "PostDairyRequestDairyInnerManureManagementMilkingCows", + "PostDairyRequestDairyInnerSeasonalFertiliser", + "PostDairyRequestDairyInnerSeasonalFertiliserAutumn", + "PostDairyRequestVegetationInner", + "PostDeer200Response", + "PostDeer200ResponseIntensities", + "PostDeer200ResponseIntermediateInner", + "PostDeer200ResponseNet", + "PostDeerRequest", + "PostDeerRequestDeersInner", + "PostDeerRequestDeersInnerClasses", + "PostDeerRequestDeersInnerClassesBreedingDoes", + "PostDeerRequestDeersInnerClassesBucks", + "PostDeerRequestDeersInnerClassesFawn", + "PostDeerRequestDeersInnerClassesOtherDoes", + "PostDeerRequestDeersInnerClassesTradeBucks", + "PostDeerRequestDeersInnerClassesTradeDoes", + "PostDeerRequestDeersInnerClassesTradeFawn", + "PostDeerRequestDeersInnerClassesTradeOtherDoes", + "PostDeerRequestDeersInnerDoesFawning", + "PostDeerRequestDeersInnerSeasonalFawning", + "PostDeerRequestVegetationInner", + "PostFeedlot200Response", + "PostFeedlot200ResponseIntermediateInner", + "PostFeedlot200ResponseIntermediateInnerIntensities", + "PostFeedlot200ResponseIntermediateInnerNet", + "PostFeedlot200ResponseScope1", + "PostFeedlot200ResponseScope3", + "PostFeedlotRequest", + "PostFeedlotRequestFeedlotsInner", + "PostFeedlotRequestFeedlotsInnerGroupsInner", + "PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner", + "PostFeedlotRequestFeedlotsInnerPurchases", + "PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner", + "PostFeedlotRequestFeedlotsInnerSales", + "PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner", + "PostFeedlotRequestVegetationInner", + "PostGoat200Response", + "PostGoat200ResponseIntensities", + "PostGoat200ResponseIntermediateInner", + "PostGoat200ResponseNet", + "PostGoatRequest", + "PostGoatRequestGoatsInner", + "PostGoatRequestGoatsInnerClasses", + "PostGoatRequestGoatsInnerClassesBreedingDoesNannies", + "PostGoatRequestGoatsInnerClassesBucksBilly", + "PostGoatRequestGoatsInnerClassesKids", + "PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies", + "PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales", + "PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies", + "PostGoatRequestGoatsInnerClassesTradeBucks", + "PostGoatRequestGoatsInnerClassesTradeDoes", + "PostGoatRequestGoatsInnerClassesTradeKids", + "PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies", + "PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales", + "PostGoatRequestGoatsInnerClassesTradeWethers", + "PostGoatRequestGoatsInnerClassesWethers", + "PostGoatRequestVegetationInner", + "PostGrains200Response", + "PostGrains200ResponseIntermediateInner", + "PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration", + "PostGrainsRequest", + "PostGrainsRequestCropsInner", + "PostHorticulture200Response", + "PostHorticulture200ResponseIntermediateInner", + "PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration", + "PostHorticulture200ResponseScope1", + "PostHorticultureRequest", + "PostHorticultureRequestCropsInner", + "PostHorticultureRequestCropsInnerRefrigerantsInner", + "PostPork200Response", + "PostPork200ResponseIntensities", + "PostPork200ResponseIntermediateInner", + "PostPork200ResponseNet", + "PostPork200ResponseScope1", + "PostPork200ResponseScope3", + "PostPorkRequest", + "PostPorkRequestPorkInner", + "PostPorkRequestPorkInnerClasses", + "PostPorkRequestPorkInnerClassesBoars", + "PostPorkRequestPorkInnerClassesGilts", + "PostPorkRequestPorkInnerClassesGrowers", + "PostPorkRequestPorkInnerClassesSlaughterPigs", + "PostPorkRequestPorkInnerClassesSows", + "PostPorkRequestPorkInnerClassesSowsManure", + "PostPorkRequestPorkInnerClassesSowsManureSpring", + "PostPorkRequestPorkInnerClassesSuckers", + "PostPorkRequestPorkInnerClassesWeaners", + "PostPorkRequestPorkInnerFeedProductsInner", + "PostPorkRequestPorkInnerFeedProductsInnerIngredients", + "PostPorkRequestVegetationInner", + "PostPoultry200Response", + "PostPoultry200ResponseIntensities", + "PostPoultry200ResponseIntermediateBroilersInner", + "PostPoultry200ResponseIntermediateBroilersInnerIntensities", + "PostPoultry200ResponseIntermediateLayersInner", + "PostPoultry200ResponseIntermediateLayersInnerIntensities", + "PostPoultry200ResponseNet", + "PostPoultry200ResponseScope1", + "PostPoultry200ResponseScope3", + "PostPoultryRequest", + "PostPoultryRequestBroilersInner", + "PostPoultryRequestBroilersInnerGroupsInner", + "PostPoultryRequestBroilersInnerGroupsInnerFeedInner", + "PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients", + "PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers", + "PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases", + "PostPoultryRequestBroilersInnerMeatChickenLayersPurchases", + "PostPoultryRequestBroilersInnerMeatOtherPurchases", + "PostPoultryRequestBroilersInnerSalesInner", + "PostPoultryRequestLayersInner", + "PostPoultryRequestLayersInnerLayers", + "PostPoultryRequestLayersInnerLayersEggSale", + "PostPoultryRequestLayersInnerLayersPurchases", + "PostPoultryRequestLayersInnerMeatChickenLayers", + "PostPoultryRequestLayersInnerMeatChickenLayersEggSale", + "PostPoultryRequestVegetationInner", + "PostProcessing200Response", + "PostProcessing200ResponseIntensitiesInner", + "PostProcessing200ResponseIntermediateInner", + "PostProcessing200ResponseNet", + "PostProcessing200ResponseScope1", + "PostProcessing200ResponseScope3", + "PostProcessingRequest", + "PostProcessingRequestProductsInner", + "PostProcessingRequestProductsInnerProduct", + "PostRice200Response", + "PostRice200ResponseIntensities", + "PostRice200ResponseIntermediateInner", + "PostRice200ResponseIntermediateInnerIntensities", + "PostRice200ResponseScope1", + "PostRiceRequest", + "PostRiceRequestCropsInner", + "PostSheep200Response", + "PostSheep200ResponseIntermediateInner", + "PostSheep200ResponseIntermediateInnerIntensities", + "PostSheep200ResponseNet", + "PostSheepRequest", + "PostSheepRequestSheepInner", + "PostSheepRequestSheepInnerClasses", + "PostSheepRequestSheepInnerClassesRams", + "PostSheepRequestSheepInnerClassesRamsAutumn", + "PostSheepRequestSheepInnerClassesTradeEwes", + "PostSheepRequestSheepInnerClassesTradeLambsAndHoggets", + "PostSheepRequestSheepInnerEwesLambing", + "PostSheepRequestSheepInnerSeasonalLambing", + "PostSheepRequestVegetationInner", + "PostSheepbeef200Response", + "PostSheepbeef200ResponseIntensities", + "PostSheepbeef200ResponseIntermediate", + "PostSheepbeef200ResponseIntermediateBeef", + "PostSheepbeef200ResponseIntermediateSheep", + "PostSheepbeef200ResponseNet", + "PostSheepbeefRequest", + "PostSheepbeefRequestVegetationInner", + "PostSugar200Response", + "PostSugar200ResponseIntermediateInner", + "PostSugar200ResponseIntermediateInnerIntensities", + "PostSugarRequest", + "PostSugarRequestCropsInner", + "PostVineyard200Response", + "PostVineyard200ResponseIntermediateInner", + "PostVineyard200ResponseIntermediateInnerIntensities", + "PostVineyard200ResponseNet", + "PostVineyard200ResponseScope1", + "PostVineyard200ResponseScope3", + "PostVineyardRequest", + "PostVineyardRequestVegetationInner", + "PostVineyardRequestVineyardsInner", + "PostWildcatchfishery200Response", + "PostWildcatchfishery200ResponseIntensities", + "PostWildcatchfishery200ResponseIntermediateInner", + "PostWildcatchfishery200ResponseScope1", + "PostWildcatchfisheryRequest", + "PostWildcatchfisheryRequestEnterprisesInner", + "PostWildcatchfisheryRequestEnterprisesInnerBaitInner", + "PostWildseafisheries200Response", + "PostWildseafisheries200ResponseIntermediateInner", + "PostWildseafisheries200ResponseIntermediateInnerIntensities", + "PostWildseafisheries200ResponseScope1", + "PostWildseafisheries200ResponseScope3", + "PostWildseafisheriesRequest", + "PostWildseafisheriesRequestEnterprisesInner", + "PostWildseafisheriesRequestEnterprisesInnerBaitInner", + "PostWildseafisheriesRequestEnterprisesInnerCustombaitInner", + "PostWildseafisheriesRequestEnterprisesInnerFlightsInner", + "PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner", + "PostWildseafisheriesRequestEnterprisesInnerTransportsInner", +] + +# import apis into sdk package +from openapi_client.api.gaf_api import GAFApi as GAFApi + +# import ApiClient +from openapi_client.api_response import ApiResponse as ApiResponse +from openapi_client.api_client import ApiClient as ApiClient +from openapi_client.configuration import Configuration as Configuration +from openapi_client.exceptions import OpenApiException as OpenApiException +from openapi_client.exceptions import ApiTypeError as ApiTypeError +from openapi_client.exceptions import ApiValueError as ApiValueError +from openapi_client.exceptions import ApiKeyError as ApiKeyError +from openapi_client.exceptions import ApiAttributeError as ApiAttributeError +from openapi_client.exceptions import ApiException as ApiException + +# import models into sdk package +from openapi_client.models.post_aquaculture200_response import PostAquaculture200Response as PostAquaculture200Response +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration as PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_intensities import PostAquaculture200ResponseIntensities as PostAquaculture200ResponseIntensities +from openapi_client.models.post_aquaculture200_response_intermediate_inner import PostAquaculture200ResponseIntermediateInner as PostAquaculture200ResponseIntermediateInner +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration as PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet as PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets as PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope1 import PostAquaculture200ResponseScope1 as PostAquaculture200ResponseScope1 +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 as PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 as PostAquaculture200ResponseScope3 +from openapi_client.models.post_aquaculture_request import PostAquacultureRequest as PostAquacultureRequest +from openapi_client.models.post_aquaculture_request_enterprises_inner import PostAquacultureRequestEnterprisesInner as PostAquacultureRequestEnterprisesInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_bait_inner import PostAquacultureRequestEnterprisesInnerBaitInner as PostAquacultureRequestEnterprisesInnerBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_custom_bait_inner import PostAquacultureRequestEnterprisesInnerCustomBaitInner as PostAquacultureRequestEnterprisesInnerCustomBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner as PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel as PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner as PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner as PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_inbound_freight_inner import PostAquacultureRequestEnterprisesInnerInboundFreightInner as PostAquacultureRequestEnterprisesInnerInboundFreightInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_refrigerants_inner import PostAquacultureRequestEnterprisesInnerRefrigerantsInner as PostAquacultureRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste as PostAquacultureRequestEnterprisesInnerSolidWaste +from openapi_client.models.post_beef200_response import PostBeef200Response as PostBeef200Response +from openapi_client.models.post_beef200_response_intermediate_inner import PostBeef200ResponseIntermediateInner as PostBeef200ResponseIntermediateInner +from openapi_client.models.post_beef200_response_intermediate_inner_intensities import PostBeef200ResponseIntermediateInnerIntensities as PostBeef200ResponseIntermediateInnerIntensities +from openapi_client.models.post_beef200_response_net import PostBeef200ResponseNet as PostBeef200ResponseNet +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 as PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 as PostBeef200ResponseScope3 +from openapi_client.models.post_beef_request import PostBeefRequest as PostBeefRequest +from openapi_client.models.post_beef_request_beef_inner import PostBeefRequestBeefInner as PostBeefRequestBeefInner +from openapi_client.models.post_beef_request_beef_inner_classes import PostBeefRequestBeefInnerClasses as PostBeefRequestBeefInnerClasses +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1 import PostBeefRequestBeefInnerClassesBullsGt1 as PostBeefRequestBeefInnerClassesBullsGt1 +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn as PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner as PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_traded import PostBeefRequestBeefInnerClassesBullsGt1Traded as PostBeefRequestBeefInnerClassesBullsGt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2 import PostBeefRequestBeefInnerClassesCowsGt2 as PostBeefRequestBeefInnerClassesCowsGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2_traded import PostBeefRequestBeefInnerClassesCowsGt2Traded as PostBeefRequestBeefInnerClassesCowsGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2 import PostBeefRequestBeefInnerClassesHeifers1To2 as PostBeefRequestBeefInnerClassesHeifers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2_traded import PostBeefRequestBeefInnerClassesHeifers1To2Traded as PostBeefRequestBeefInnerClassesHeifers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2 import PostBeefRequestBeefInnerClassesHeifersGt2 as PostBeefRequestBeefInnerClassesHeifersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2_traded import PostBeefRequestBeefInnerClassesHeifersGt2Traded as PostBeefRequestBeefInnerClassesHeifersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1 import PostBeefRequestBeefInnerClassesHeifersLt1 as PostBeefRequestBeefInnerClassesHeifersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1_traded import PostBeefRequestBeefInnerClassesHeifersLt1Traded as PostBeefRequestBeefInnerClassesHeifersLt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2 import PostBeefRequestBeefInnerClassesSteers1To2 as PostBeefRequestBeefInnerClassesSteers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2_traded import PostBeefRequestBeefInnerClassesSteers1To2Traded as PostBeefRequestBeefInnerClassesSteers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2 import PostBeefRequestBeefInnerClassesSteersGt2 as PostBeefRequestBeefInnerClassesSteersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2_traded import PostBeefRequestBeefInnerClassesSteersGt2Traded as PostBeefRequestBeefInnerClassesSteersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1 import PostBeefRequestBeefInnerClassesSteersLt1 as PostBeefRequestBeefInnerClassesSteersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1_traded import PostBeefRequestBeefInnerClassesSteersLt1Traded as PostBeefRequestBeefInnerClassesSteersLt1Traded +from openapi_client.models.post_beef_request_beef_inner_cows_calving import PostBeefRequestBeefInnerCowsCalving as PostBeefRequestBeefInnerCowsCalving +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser as PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_beef_request_beef_inner_fertiliser_other_fertilisers_inner import PostBeefRequestBeefInnerFertiliserOtherFertilisersInner as PostBeefRequestBeefInnerFertiliserOtherFertilisersInner +from openapi_client.models.post_beef_request_beef_inner_mineral_supplementation import PostBeefRequestBeefInnerMineralSupplementation as PostBeefRequestBeefInnerMineralSupplementation +from openapi_client.models.post_beef_request_burning_inner import PostBeefRequestBurningInner as PostBeefRequestBurningInner +from openapi_client.models.post_beef_request_burning_inner_burning import PostBeefRequestBurningInnerBurning as PostBeefRequestBurningInnerBurning +from openapi_client.models.post_beef_request_vegetation_inner import PostBeefRequestVegetationInner as PostBeefRequestVegetationInner +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation as PostBeefRequestVegetationInnerVegetation +from openapi_client.models.post_buffalo200_response import PostBuffalo200Response as PostBuffalo200Response +from openapi_client.models.post_buffalo200_response_intensities import PostBuffalo200ResponseIntensities as PostBuffalo200ResponseIntensities +from openapi_client.models.post_buffalo200_response_intermediate_inner import PostBuffalo200ResponseIntermediateInner as PostBuffalo200ResponseIntermediateInner +from openapi_client.models.post_buffalo200_response_net import PostBuffalo200ResponseNet as PostBuffalo200ResponseNet +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 as PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 as PostBuffalo200ResponseScope3 +from openapi_client.models.post_buffalo_request import PostBuffaloRequest as PostBuffaloRequest +from openapi_client.models.post_buffalo_request_buffalos_inner import PostBuffaloRequestBuffalosInner as PostBuffaloRequestBuffalosInner +from openapi_client.models.post_buffalo_request_buffalos_inner_classes import PostBuffaloRequestBuffalosInnerClasses as PostBuffaloRequestBuffalosInnerClasses +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls import PostBuffaloRequestBuffalosInnerClassesBulls as PostBuffaloRequestBuffalosInnerClassesBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn as PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner as PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_calfs import PostBuffaloRequestBuffalosInnerClassesCalfs as PostBuffaloRequestBuffalosInnerClassesCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_cows import PostBuffaloRequestBuffalosInnerClassesCows as PostBuffaloRequestBuffalosInnerClassesCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_steers import PostBuffaloRequestBuffalosInnerClassesSteers as PostBuffaloRequestBuffalosInnerClassesSteers +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_bulls import PostBuffaloRequestBuffalosInnerClassesTradeBulls as PostBuffaloRequestBuffalosInnerClassesTradeBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_calfs import PostBuffaloRequestBuffalosInnerClassesTradeCalfs as PostBuffaloRequestBuffalosInnerClassesTradeCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_cows import PostBuffaloRequestBuffalosInnerClassesTradeCows as PostBuffaloRequestBuffalosInnerClassesTradeCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_steers import PostBuffaloRequestBuffalosInnerClassesTradeSteers as PostBuffaloRequestBuffalosInnerClassesTradeSteers +from openapi_client.models.post_buffalo_request_buffalos_inner_cows_calving import PostBuffaloRequestBuffalosInnerCowsCalving as PostBuffaloRequestBuffalosInnerCowsCalving +from openapi_client.models.post_buffalo_request_buffalos_inner_seasonal_calving import PostBuffaloRequestBuffalosInnerSeasonalCalving as PostBuffaloRequestBuffalosInnerSeasonalCalving +from openapi_client.models.post_buffalo_request_vegetation_inner import PostBuffaloRequestVegetationInner as PostBuffaloRequestVegetationInner +from openapi_client.models.post_cotton200_response import PostCotton200Response as PostCotton200Response +from openapi_client.models.post_cotton200_response_intermediate_inner import PostCotton200ResponseIntermediateInner as PostCotton200ResponseIntermediateInner +from openapi_client.models.post_cotton200_response_intermediate_inner_intensities import PostCotton200ResponseIntermediateInnerIntensities as PostCotton200ResponseIntermediateInnerIntensities +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet as PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 as PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 as PostCotton200ResponseScope3 +from openapi_client.models.post_cotton_request import PostCottonRequest as PostCottonRequest +from openapi_client.models.post_cotton_request_crops_inner import PostCottonRequestCropsInner as PostCottonRequestCropsInner +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner as PostCottonRequestVegetationInner +from openapi_client.models.post_dairy200_response import PostDairy200Response as PostDairy200Response +from openapi_client.models.post_dairy200_response_intensities import PostDairy200ResponseIntensities as PostDairy200ResponseIntensities +from openapi_client.models.post_dairy200_response_intermediate_inner import PostDairy200ResponseIntermediateInner as PostDairy200ResponseIntermediateInner +from openapi_client.models.post_dairy200_response_net import PostDairy200ResponseNet as PostDairy200ResponseNet +from openapi_client.models.post_dairy200_response_scope1 import PostDairy200ResponseScope1 as PostDairy200ResponseScope1 +from openapi_client.models.post_dairy200_response_scope3 import PostDairy200ResponseScope3 as PostDairy200ResponseScope3 +from openapi_client.models.post_dairy_request import PostDairyRequest as PostDairyRequest +from openapi_client.models.post_dairy_request_dairy_inner import PostDairyRequestDairyInner as PostDairyRequestDairyInner +from openapi_client.models.post_dairy_request_dairy_inner_areas import PostDairyRequestDairyInnerAreas as PostDairyRequestDairyInnerAreas +from openapi_client.models.post_dairy_request_dairy_inner_classes import PostDairyRequestDairyInnerClasses as PostDairyRequestDairyInnerClasses +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_gt1 import PostDairyRequestDairyInnerClassesDairyBullsGt1 as PostDairyRequestDairyInnerClassesDairyBullsGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_lt1 import PostDairyRequestDairyInnerClassesDairyBullsLt1 as PostDairyRequestDairyInnerClassesDairyBullsLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_gt1 import PostDairyRequestDairyInnerClassesHeifersGt1 as PostDairyRequestDairyInnerClassesHeifersGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_lt1 import PostDairyRequestDairyInnerClassesHeifersLt1 as PostDairyRequestDairyInnerClassesHeifersLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows import PostDairyRequestDairyInnerClassesMilkingCows as PostDairyRequestDairyInnerClassesMilkingCows +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn as PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from openapi_client.models.post_dairy_request_dairy_inner_manure_management_milking_cows import PostDairyRequestDairyInnerManureManagementMilkingCows as PostDairyRequestDairyInnerManureManagementMilkingCows +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser import PostDairyRequestDairyInnerSeasonalFertiliser as PostDairyRequestDairyInnerSeasonalFertiliser +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser_autumn import PostDairyRequestDairyInnerSeasonalFertiliserAutumn as PostDairyRequestDairyInnerSeasonalFertiliserAutumn +from openapi_client.models.post_dairy_request_vegetation_inner import PostDairyRequestVegetationInner as PostDairyRequestVegetationInner +from openapi_client.models.post_deer200_response import PostDeer200Response as PostDeer200Response +from openapi_client.models.post_deer200_response_intensities import PostDeer200ResponseIntensities as PostDeer200ResponseIntensities +from openapi_client.models.post_deer200_response_intermediate_inner import PostDeer200ResponseIntermediateInner as PostDeer200ResponseIntermediateInner +from openapi_client.models.post_deer200_response_net import PostDeer200ResponseNet as PostDeer200ResponseNet +from openapi_client.models.post_deer_request import PostDeerRequest as PostDeerRequest +from openapi_client.models.post_deer_request_deers_inner import PostDeerRequestDeersInner as PostDeerRequestDeersInner +from openapi_client.models.post_deer_request_deers_inner_classes import PostDeerRequestDeersInnerClasses as PostDeerRequestDeersInnerClasses +from openapi_client.models.post_deer_request_deers_inner_classes_breeding_does import PostDeerRequestDeersInnerClassesBreedingDoes as PostDeerRequestDeersInnerClassesBreedingDoes +from openapi_client.models.post_deer_request_deers_inner_classes_bucks import PostDeerRequestDeersInnerClassesBucks as PostDeerRequestDeersInnerClassesBucks +from openapi_client.models.post_deer_request_deers_inner_classes_fawn import PostDeerRequestDeersInnerClassesFawn as PostDeerRequestDeersInnerClassesFawn +from openapi_client.models.post_deer_request_deers_inner_classes_other_does import PostDeerRequestDeersInnerClassesOtherDoes as PostDeerRequestDeersInnerClassesOtherDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_bucks import PostDeerRequestDeersInnerClassesTradeBucks as PostDeerRequestDeersInnerClassesTradeBucks +from openapi_client.models.post_deer_request_deers_inner_classes_trade_does import PostDeerRequestDeersInnerClassesTradeDoes as PostDeerRequestDeersInnerClassesTradeDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_fawn import PostDeerRequestDeersInnerClassesTradeFawn as PostDeerRequestDeersInnerClassesTradeFawn +from openapi_client.models.post_deer_request_deers_inner_classes_trade_other_does import PostDeerRequestDeersInnerClassesTradeOtherDoes as PostDeerRequestDeersInnerClassesTradeOtherDoes +from openapi_client.models.post_deer_request_deers_inner_does_fawning import PostDeerRequestDeersInnerDoesFawning as PostDeerRequestDeersInnerDoesFawning +from openapi_client.models.post_deer_request_deers_inner_seasonal_fawning import PostDeerRequestDeersInnerSeasonalFawning as PostDeerRequestDeersInnerSeasonalFawning +from openapi_client.models.post_deer_request_vegetation_inner import PostDeerRequestVegetationInner as PostDeerRequestVegetationInner +from openapi_client.models.post_feedlot200_response import PostFeedlot200Response as PostFeedlot200Response +from openapi_client.models.post_feedlot200_response_intermediate_inner import PostFeedlot200ResponseIntermediateInner as PostFeedlot200ResponseIntermediateInner +from openapi_client.models.post_feedlot200_response_intermediate_inner_intensities import PostFeedlot200ResponseIntermediateInnerIntensities as PostFeedlot200ResponseIntermediateInnerIntensities +from openapi_client.models.post_feedlot200_response_intermediate_inner_net import PostFeedlot200ResponseIntermediateInnerNet as PostFeedlot200ResponseIntermediateInnerNet +from openapi_client.models.post_feedlot200_response_scope1 import PostFeedlot200ResponseScope1 as PostFeedlot200ResponseScope1 +from openapi_client.models.post_feedlot200_response_scope3 import PostFeedlot200ResponseScope3 as PostFeedlot200ResponseScope3 +from openapi_client.models.post_feedlot_request import PostFeedlotRequest as PostFeedlotRequest +from openapi_client.models.post_feedlot_request_feedlots_inner import PostFeedlotRequestFeedlotsInner as PostFeedlotRequestFeedlotsInner +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner import PostFeedlotRequestFeedlotsInnerGroupsInner as PostFeedlotRequestFeedlotsInnerGroupsInner +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner_stays_inner import PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner as PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases import PostFeedlotRequestFeedlotsInnerPurchases as PostFeedlotRequestFeedlotsInnerPurchases +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner as PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner +from openapi_client.models.post_feedlot_request_feedlots_inner_sales import PostFeedlotRequestFeedlotsInnerSales as PostFeedlotRequestFeedlotsInnerSales +from openapi_client.models.post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner as PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner +from openapi_client.models.post_feedlot_request_vegetation_inner import PostFeedlotRequestVegetationInner as PostFeedlotRequestVegetationInner +from openapi_client.models.post_goat200_response import PostGoat200Response as PostGoat200Response +from openapi_client.models.post_goat200_response_intensities import PostGoat200ResponseIntensities as PostGoat200ResponseIntensities +from openapi_client.models.post_goat200_response_intermediate_inner import PostGoat200ResponseIntermediateInner as PostGoat200ResponseIntermediateInner +from openapi_client.models.post_goat200_response_net import PostGoat200ResponseNet as PostGoat200ResponseNet +from openapi_client.models.post_goat_request import PostGoatRequest as PostGoatRequest +from openapi_client.models.post_goat_request_goats_inner import PostGoatRequestGoatsInner as PostGoatRequestGoatsInner +from openapi_client.models.post_goat_request_goats_inner_classes import PostGoatRequestGoatsInnerClasses as PostGoatRequestGoatsInnerClasses +from openapi_client.models.post_goat_request_goats_inner_classes_breeding_does_nannies import PostGoatRequestGoatsInnerClassesBreedingDoesNannies as PostGoatRequestGoatsInnerClassesBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_bucks_billy import PostGoatRequestGoatsInnerClassesBucksBilly as PostGoatRequestGoatsInnerClassesBucksBilly +from openapi_client.models.post_goat_request_goats_inner_classes_kids import PostGoatRequestGoatsInnerClassesKids as PostGoatRequestGoatsInnerClassesKids +from openapi_client.models.post_goat_request_goats_inner_classes_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies as PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_other_does_culled_females import PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales as PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies as PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_bucks import PostGoatRequestGoatsInnerClassesTradeBucks as PostGoatRequestGoatsInnerClassesTradeBucks +from openapi_client.models.post_goat_request_goats_inner_classes_trade_does import PostGoatRequestGoatsInnerClassesTradeDoes as PostGoatRequestGoatsInnerClassesTradeDoes +from openapi_client.models.post_goat_request_goats_inner_classes_trade_kids import PostGoatRequestGoatsInnerClassesTradeKids as PostGoatRequestGoatsInnerClassesTradeKids +from openapi_client.models.post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies as PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_other_does_culled_females import PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales as PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_wethers import PostGoatRequestGoatsInnerClassesTradeWethers as PostGoatRequestGoatsInnerClassesTradeWethers +from openapi_client.models.post_goat_request_goats_inner_classes_wethers import PostGoatRequestGoatsInnerClassesWethers as PostGoatRequestGoatsInnerClassesWethers +from openapi_client.models.post_goat_request_vegetation_inner import PostGoatRequestVegetationInner as PostGoatRequestVegetationInner +from openapi_client.models.post_grains200_response import PostGrains200Response as PostGrains200Response +from openapi_client.models.post_grains200_response_intermediate_inner import PostGrains200ResponseIntermediateInner as PostGrains200ResponseIntermediateInner +from openapi_client.models.post_grains200_response_intermediate_inner_intensities_with_sequestration import PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration as PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_grains_request import PostGrainsRequest as PostGrainsRequest +from openapi_client.models.post_grains_request_crops_inner import PostGrainsRequestCropsInner as PostGrainsRequestCropsInner +from openapi_client.models.post_horticulture200_response import PostHorticulture200Response as PostHorticulture200Response +from openapi_client.models.post_horticulture200_response_intermediate_inner import PostHorticulture200ResponseIntermediateInner as PostHorticulture200ResponseIntermediateInner +from openapi_client.models.post_horticulture200_response_intermediate_inner_intensities_with_sequestration import PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration as PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_horticulture200_response_scope1 import PostHorticulture200ResponseScope1 as PostHorticulture200ResponseScope1 +from openapi_client.models.post_horticulture_request import PostHorticultureRequest as PostHorticultureRequest +from openapi_client.models.post_horticulture_request_crops_inner import PostHorticultureRequestCropsInner as PostHorticultureRequestCropsInner +from openapi_client.models.post_horticulture_request_crops_inner_refrigerants_inner import PostHorticultureRequestCropsInnerRefrigerantsInner as PostHorticultureRequestCropsInnerRefrigerantsInner +from openapi_client.models.post_pork200_response import PostPork200Response as PostPork200Response +from openapi_client.models.post_pork200_response_intensities import PostPork200ResponseIntensities as PostPork200ResponseIntensities +from openapi_client.models.post_pork200_response_intermediate_inner import PostPork200ResponseIntermediateInner as PostPork200ResponseIntermediateInner +from openapi_client.models.post_pork200_response_net import PostPork200ResponseNet as PostPork200ResponseNet +from openapi_client.models.post_pork200_response_scope1 import PostPork200ResponseScope1 as PostPork200ResponseScope1 +from openapi_client.models.post_pork200_response_scope3 import PostPork200ResponseScope3 as PostPork200ResponseScope3 +from openapi_client.models.post_pork_request import PostPorkRequest as PostPorkRequest +from openapi_client.models.post_pork_request_pork_inner import PostPorkRequestPorkInner as PostPorkRequestPorkInner +from openapi_client.models.post_pork_request_pork_inner_classes import PostPorkRequestPorkInnerClasses as PostPorkRequestPorkInnerClasses +from openapi_client.models.post_pork_request_pork_inner_classes_boars import PostPorkRequestPorkInnerClassesBoars as PostPorkRequestPorkInnerClassesBoars +from openapi_client.models.post_pork_request_pork_inner_classes_gilts import PostPorkRequestPorkInnerClassesGilts as PostPorkRequestPorkInnerClassesGilts +from openapi_client.models.post_pork_request_pork_inner_classes_growers import PostPorkRequestPorkInnerClassesGrowers as PostPorkRequestPorkInnerClassesGrowers +from openapi_client.models.post_pork_request_pork_inner_classes_slaughter_pigs import PostPorkRequestPorkInnerClassesSlaughterPigs as PostPorkRequestPorkInnerClassesSlaughterPigs +from openapi_client.models.post_pork_request_pork_inner_classes_sows import PostPorkRequestPorkInnerClassesSows as PostPorkRequestPorkInnerClassesSows +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure as PostPorkRequestPorkInnerClassesSowsManure +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure_spring import PostPorkRequestPorkInnerClassesSowsManureSpring as PostPorkRequestPorkInnerClassesSowsManureSpring +from openapi_client.models.post_pork_request_pork_inner_classes_suckers import PostPorkRequestPorkInnerClassesSuckers as PostPorkRequestPorkInnerClassesSuckers +from openapi_client.models.post_pork_request_pork_inner_classes_weaners import PostPorkRequestPorkInnerClassesWeaners as PostPorkRequestPorkInnerClassesWeaners +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner import PostPorkRequestPorkInnerFeedProductsInner as PostPorkRequestPorkInnerFeedProductsInner +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner_ingredients import PostPorkRequestPorkInnerFeedProductsInnerIngredients as PostPorkRequestPorkInnerFeedProductsInnerIngredients +from openapi_client.models.post_pork_request_vegetation_inner import PostPorkRequestVegetationInner as PostPorkRequestVegetationInner +from openapi_client.models.post_poultry200_response import PostPoultry200Response as PostPoultry200Response +from openapi_client.models.post_poultry200_response_intensities import PostPoultry200ResponseIntensities as PostPoultry200ResponseIntensities +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner import PostPoultry200ResponseIntermediateBroilersInner as PostPoultry200ResponseIntermediateBroilersInner +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner_intensities import PostPoultry200ResponseIntermediateBroilersInnerIntensities as PostPoultry200ResponseIntermediateBroilersInnerIntensities +from openapi_client.models.post_poultry200_response_intermediate_layers_inner import PostPoultry200ResponseIntermediateLayersInner as PostPoultry200ResponseIntermediateLayersInner +from openapi_client.models.post_poultry200_response_intermediate_layers_inner_intensities import PostPoultry200ResponseIntermediateLayersInnerIntensities as PostPoultry200ResponseIntermediateLayersInnerIntensities +from openapi_client.models.post_poultry200_response_net import PostPoultry200ResponseNet as PostPoultry200ResponseNet +from openapi_client.models.post_poultry200_response_scope1 import PostPoultry200ResponseScope1 as PostPoultry200ResponseScope1 +from openapi_client.models.post_poultry200_response_scope3 import PostPoultry200ResponseScope3 as PostPoultry200ResponseScope3 +from openapi_client.models.post_poultry_request import PostPoultryRequest as PostPoultryRequest +from openapi_client.models.post_poultry_request_broilers_inner import PostPoultryRequestBroilersInner as PostPoultryRequestBroilersInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner import PostPoultryRequestBroilersInnerGroupsInner as PostPoultryRequestBroilersInnerGroupsInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner import PostPoultryRequestBroilersInnerGroupsInnerFeedInner as PostPoultryRequestBroilersInnerGroupsInnerFeedInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients import PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients as PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers import PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers as PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_growers_purchases import PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases as PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_layers_purchases import PostPoultryRequestBroilersInnerMeatChickenLayersPurchases as PostPoultryRequestBroilersInnerMeatChickenLayersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_other_purchases import PostPoultryRequestBroilersInnerMeatOtherPurchases as PostPoultryRequestBroilersInnerMeatOtherPurchases +from openapi_client.models.post_poultry_request_broilers_inner_sales_inner import PostPoultryRequestBroilersInnerSalesInner as PostPoultryRequestBroilersInnerSalesInner +from openapi_client.models.post_poultry_request_layers_inner import PostPoultryRequestLayersInner as PostPoultryRequestLayersInner +from openapi_client.models.post_poultry_request_layers_inner_layers import PostPoultryRequestLayersInnerLayers as PostPoultryRequestLayersInnerLayers +from openapi_client.models.post_poultry_request_layers_inner_layers_egg_sale import PostPoultryRequestLayersInnerLayersEggSale as PostPoultryRequestLayersInnerLayersEggSale +from openapi_client.models.post_poultry_request_layers_inner_layers_purchases import PostPoultryRequestLayersInnerLayersPurchases as PostPoultryRequestLayersInnerLayersPurchases +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers import PostPoultryRequestLayersInnerMeatChickenLayers as PostPoultryRequestLayersInnerMeatChickenLayers +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers_egg_sale import PostPoultryRequestLayersInnerMeatChickenLayersEggSale as PostPoultryRequestLayersInnerMeatChickenLayersEggSale +from openapi_client.models.post_poultry_request_vegetation_inner import PostPoultryRequestVegetationInner as PostPoultryRequestVegetationInner +from openapi_client.models.post_processing200_response import PostProcessing200Response as PostProcessing200Response +from openapi_client.models.post_processing200_response_intensities_inner import PostProcessing200ResponseIntensitiesInner as PostProcessing200ResponseIntensitiesInner +from openapi_client.models.post_processing200_response_intermediate_inner import PostProcessing200ResponseIntermediateInner as PostProcessing200ResponseIntermediateInner +from openapi_client.models.post_processing200_response_net import PostProcessing200ResponseNet as PostProcessing200ResponseNet +from openapi_client.models.post_processing200_response_scope1 import PostProcessing200ResponseScope1 as PostProcessing200ResponseScope1 +from openapi_client.models.post_processing200_response_scope3 import PostProcessing200ResponseScope3 as PostProcessing200ResponseScope3 +from openapi_client.models.post_processing_request import PostProcessingRequest as PostProcessingRequest +from openapi_client.models.post_processing_request_products_inner import PostProcessingRequestProductsInner as PostProcessingRequestProductsInner +from openapi_client.models.post_processing_request_products_inner_product import PostProcessingRequestProductsInnerProduct as PostProcessingRequestProductsInnerProduct +from openapi_client.models.post_rice200_response import PostRice200Response as PostRice200Response +from openapi_client.models.post_rice200_response_intensities import PostRice200ResponseIntensities as PostRice200ResponseIntensities +from openapi_client.models.post_rice200_response_intermediate_inner import PostRice200ResponseIntermediateInner as PostRice200ResponseIntermediateInner +from openapi_client.models.post_rice200_response_intermediate_inner_intensities import PostRice200ResponseIntermediateInnerIntensities as PostRice200ResponseIntermediateInnerIntensities +from openapi_client.models.post_rice200_response_scope1 import PostRice200ResponseScope1 as PostRice200ResponseScope1 +from openapi_client.models.post_rice_request import PostRiceRequest as PostRiceRequest +from openapi_client.models.post_rice_request_crops_inner import PostRiceRequestCropsInner as PostRiceRequestCropsInner +from openapi_client.models.post_sheep200_response import PostSheep200Response as PostSheep200Response +from openapi_client.models.post_sheep200_response_intermediate_inner import PostSheep200ResponseIntermediateInner as PostSheep200ResponseIntermediateInner +from openapi_client.models.post_sheep200_response_intermediate_inner_intensities import PostSheep200ResponseIntermediateInnerIntensities as PostSheep200ResponseIntermediateInnerIntensities +from openapi_client.models.post_sheep200_response_net import PostSheep200ResponseNet as PostSheep200ResponseNet +from openapi_client.models.post_sheep_request import PostSheepRequest as PostSheepRequest +from openapi_client.models.post_sheep_request_sheep_inner import PostSheepRequestSheepInner as PostSheepRequestSheepInner +from openapi_client.models.post_sheep_request_sheep_inner_classes import PostSheepRequestSheepInnerClasses as PostSheepRequestSheepInnerClasses +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams import PostSheepRequestSheepInnerClassesRams as PostSheepRequestSheepInnerClassesRams +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams_autumn import PostSheepRequestSheepInnerClassesRamsAutumn as PostSheepRequestSheepInnerClassesRamsAutumn +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_ewes import PostSheepRequestSheepInnerClassesTradeEwes as PostSheepRequestSheepInnerClassesTradeEwes +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets import PostSheepRequestSheepInnerClassesTradeLambsAndHoggets as PostSheepRequestSheepInnerClassesTradeLambsAndHoggets +from openapi_client.models.post_sheep_request_sheep_inner_ewes_lambing import PostSheepRequestSheepInnerEwesLambing as PostSheepRequestSheepInnerEwesLambing +from openapi_client.models.post_sheep_request_sheep_inner_seasonal_lambing import PostSheepRequestSheepInnerSeasonalLambing as PostSheepRequestSheepInnerSeasonalLambing +from openapi_client.models.post_sheep_request_vegetation_inner import PostSheepRequestVegetationInner as PostSheepRequestVegetationInner +from openapi_client.models.post_sheepbeef200_response import PostSheepbeef200Response as PostSheepbeef200Response +from openapi_client.models.post_sheepbeef200_response_intensities import PostSheepbeef200ResponseIntensities as PostSheepbeef200ResponseIntensities +from openapi_client.models.post_sheepbeef200_response_intermediate import PostSheepbeef200ResponseIntermediate as PostSheepbeef200ResponseIntermediate +from openapi_client.models.post_sheepbeef200_response_intermediate_beef import PostSheepbeef200ResponseIntermediateBeef as PostSheepbeef200ResponseIntermediateBeef +from openapi_client.models.post_sheepbeef200_response_intermediate_sheep import PostSheepbeef200ResponseIntermediateSheep as PostSheepbeef200ResponseIntermediateSheep +from openapi_client.models.post_sheepbeef200_response_net import PostSheepbeef200ResponseNet as PostSheepbeef200ResponseNet +from openapi_client.models.post_sheepbeef_request import PostSheepbeefRequest as PostSheepbeefRequest +from openapi_client.models.post_sheepbeef_request_vegetation_inner import PostSheepbeefRequestVegetationInner as PostSheepbeefRequestVegetationInner +from openapi_client.models.post_sugar200_response import PostSugar200Response as PostSugar200Response +from openapi_client.models.post_sugar200_response_intermediate_inner import PostSugar200ResponseIntermediateInner as PostSugar200ResponseIntermediateInner +from openapi_client.models.post_sugar200_response_intermediate_inner_intensities import PostSugar200ResponseIntermediateInnerIntensities as PostSugar200ResponseIntermediateInnerIntensities +from openapi_client.models.post_sugar_request import PostSugarRequest as PostSugarRequest +from openapi_client.models.post_sugar_request_crops_inner import PostSugarRequestCropsInner as PostSugarRequestCropsInner +from openapi_client.models.post_vineyard200_response import PostVineyard200Response as PostVineyard200Response +from openapi_client.models.post_vineyard200_response_intermediate_inner import PostVineyard200ResponseIntermediateInner as PostVineyard200ResponseIntermediateInner +from openapi_client.models.post_vineyard200_response_intermediate_inner_intensities import PostVineyard200ResponseIntermediateInnerIntensities as PostVineyard200ResponseIntermediateInnerIntensities +from openapi_client.models.post_vineyard200_response_net import PostVineyard200ResponseNet as PostVineyard200ResponseNet +from openapi_client.models.post_vineyard200_response_scope1 import PostVineyard200ResponseScope1 as PostVineyard200ResponseScope1 +from openapi_client.models.post_vineyard200_response_scope3 import PostVineyard200ResponseScope3 as PostVineyard200ResponseScope3 +from openapi_client.models.post_vineyard_request import PostVineyardRequest as PostVineyardRequest +from openapi_client.models.post_vineyard_request_vegetation_inner import PostVineyardRequestVegetationInner as PostVineyardRequestVegetationInner +from openapi_client.models.post_vineyard_request_vineyards_inner import PostVineyardRequestVineyardsInner as PostVineyardRequestVineyardsInner +from openapi_client.models.post_wildcatchfishery200_response import PostWildcatchfishery200Response as PostWildcatchfishery200Response +from openapi_client.models.post_wildcatchfishery200_response_intensities import PostWildcatchfishery200ResponseIntensities as PostWildcatchfishery200ResponseIntensities +from openapi_client.models.post_wildcatchfishery200_response_intermediate_inner import PostWildcatchfishery200ResponseIntermediateInner as PostWildcatchfishery200ResponseIntermediateInner +from openapi_client.models.post_wildcatchfishery200_response_scope1 import PostWildcatchfishery200ResponseScope1 as PostWildcatchfishery200ResponseScope1 +from openapi_client.models.post_wildcatchfishery_request import PostWildcatchfisheryRequest as PostWildcatchfisheryRequest +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner import PostWildcatchfisheryRequestEnterprisesInner as PostWildcatchfisheryRequestEnterprisesInner +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner_bait_inner import PostWildcatchfisheryRequestEnterprisesInnerBaitInner as PostWildcatchfisheryRequestEnterprisesInnerBaitInner +from openapi_client.models.post_wildseafisheries200_response import PostWildseafisheries200Response as PostWildseafisheries200Response +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner import PostWildseafisheries200ResponseIntermediateInner as PostWildseafisheries200ResponseIntermediateInner +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner_intensities import PostWildseafisheries200ResponseIntermediateInnerIntensities as PostWildseafisheries200ResponseIntermediateInnerIntensities +from openapi_client.models.post_wildseafisheries200_response_scope1 import PostWildseafisheries200ResponseScope1 as PostWildseafisheries200ResponseScope1 +from openapi_client.models.post_wildseafisheries200_response_scope3 import PostWildseafisheries200ResponseScope3 as PostWildseafisheries200ResponseScope3 +from openapi_client.models.post_wildseafisheries_request import PostWildseafisheriesRequest as PostWildseafisheriesRequest +from openapi_client.models.post_wildseafisheries_request_enterprises_inner import PostWildseafisheriesRequestEnterprisesInner as PostWildseafisheriesRequestEnterprisesInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_bait_inner import PostWildseafisheriesRequestEnterprisesInnerBaitInner as PostWildseafisheriesRequestEnterprisesInnerBaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_custombait_inner import PostWildseafisheriesRequestEnterprisesInnerCustombaitInner as PostWildseafisheriesRequestEnterprisesInnerCustombaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_flights_inner import PostWildseafisheriesRequestEnterprisesInnerFlightsInner as PostWildseafisheriesRequestEnterprisesInnerFlightsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_refrigerants_inner import PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner as PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_transports_inner import PostWildseafisheriesRequestEnterprisesInnerTransportsInner as PostWildseafisheriesRequestEnterprisesInnerTransportsInner diff --git a/examples/python-api-client/api-client/openapi_client/api/__init__.py b/examples/python-api-client/api-client/openapi_client/api/__init__.py new file mode 100644 index 00000000..8ea552ff --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/api/__init__.py @@ -0,0 +1,5 @@ +# flake8: noqa + +# import apis into api package +from openapi_client.api.gaf_api import GAFApi + diff --git a/examples/python-api-client/api-client/openapi_client/api/gaf_api.py b/examples/python-api-client/api-client/openapi_client/api/gaf_api.py new file mode 100644 index 00000000..37d5f8b3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/api/gaf_api.py @@ -0,0 +1,5596 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from openapi_client.models.post_aquaculture200_response import PostAquaculture200Response +from openapi_client.models.post_aquaculture_request import PostAquacultureRequest +from openapi_client.models.post_beef200_response import PostBeef200Response +from openapi_client.models.post_beef_request import PostBeefRequest +from openapi_client.models.post_buffalo200_response import PostBuffalo200Response +from openapi_client.models.post_buffalo_request import PostBuffaloRequest +from openapi_client.models.post_cotton200_response import PostCotton200Response +from openapi_client.models.post_cotton_request import PostCottonRequest +from openapi_client.models.post_dairy200_response import PostDairy200Response +from openapi_client.models.post_dairy_request import PostDairyRequest +from openapi_client.models.post_deer200_response import PostDeer200Response +from openapi_client.models.post_deer_request import PostDeerRequest +from openapi_client.models.post_feedlot200_response import PostFeedlot200Response +from openapi_client.models.post_feedlot_request import PostFeedlotRequest +from openapi_client.models.post_goat200_response import PostGoat200Response +from openapi_client.models.post_goat_request import PostGoatRequest +from openapi_client.models.post_grains200_response import PostGrains200Response +from openapi_client.models.post_grains_request import PostGrainsRequest +from openapi_client.models.post_horticulture200_response import PostHorticulture200Response +from openapi_client.models.post_horticulture_request import PostHorticultureRequest +from openapi_client.models.post_pork200_response import PostPork200Response +from openapi_client.models.post_pork_request import PostPorkRequest +from openapi_client.models.post_poultry200_response import PostPoultry200Response +from openapi_client.models.post_poultry_request import PostPoultryRequest +from openapi_client.models.post_processing200_response import PostProcessing200Response +from openapi_client.models.post_processing_request import PostProcessingRequest +from openapi_client.models.post_rice200_response import PostRice200Response +from openapi_client.models.post_rice_request import PostRiceRequest +from openapi_client.models.post_sheep200_response import PostSheep200Response +from openapi_client.models.post_sheep_request import PostSheepRequest +from openapi_client.models.post_sheepbeef200_response import PostSheepbeef200Response +from openapi_client.models.post_sheepbeef_request import PostSheepbeefRequest +from openapi_client.models.post_sugar200_response import PostSugar200Response +from openapi_client.models.post_sugar_request import PostSugarRequest +from openapi_client.models.post_vineyard200_response import PostVineyard200Response +from openapi_client.models.post_vineyard_request import PostVineyardRequest +from openapi_client.models.post_wildcatchfishery200_response import PostWildcatchfishery200Response +from openapi_client.models.post_wildcatchfishery_request import PostWildcatchfisheryRequest +from openapi_client.models.post_wildseafisheries200_response import PostWildseafisheries200Response +from openapi_client.models.post_wildseafisheries_request import PostWildseafisheriesRequest + +from openapi_client.api_client import ApiClient, RequestSerialized +from openapi_client.api_response import ApiResponse +from openapi_client.rest import RESTResponseType + + +class GAFApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def post_aquaculture( + self, + post_aquaculture_request: PostAquacultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostAquaculture200Response: + """Perform aquaculture calculation + + Retrieve a simple JSON response + + :param post_aquaculture_request: (required) + :type post_aquaculture_request: PostAquacultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_aquaculture_serialize( + post_aquaculture_request=post_aquaculture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostAquaculture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_aquaculture_with_http_info( + self, + post_aquaculture_request: PostAquacultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostAquaculture200Response]: + """Perform aquaculture calculation + + Retrieve a simple JSON response + + :param post_aquaculture_request: (required) + :type post_aquaculture_request: PostAquacultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_aquaculture_serialize( + post_aquaculture_request=post_aquaculture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostAquaculture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_aquaculture_without_preload_content( + self, + post_aquaculture_request: PostAquacultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform aquaculture calculation + + Retrieve a simple JSON response + + :param post_aquaculture_request: (required) + :type post_aquaculture_request: PostAquacultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_aquaculture_serialize( + post_aquaculture_request=post_aquaculture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostAquaculture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_aquaculture_serialize( + self, + post_aquaculture_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_aquaculture_request is not None: + _body_params = post_aquaculture_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/aquaculture', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_beef( + self, + post_beef_request: PostBeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostBeef200Response: + """Perform beef calculation + + Retrieve a simple JSON response + + :param post_beef_request: (required) + :type post_beef_request: PostBeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_beef_serialize( + post_beef_request=post_beef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_beef_with_http_info( + self, + post_beef_request: PostBeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostBeef200Response]: + """Perform beef calculation + + Retrieve a simple JSON response + + :param post_beef_request: (required) + :type post_beef_request: PostBeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_beef_serialize( + post_beef_request=post_beef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_beef_without_preload_content( + self, + post_beef_request: PostBeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform beef calculation + + Retrieve a simple JSON response + + :param post_beef_request: (required) + :type post_beef_request: PostBeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_beef_serialize( + post_beef_request=post_beef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_beef_serialize( + self, + post_beef_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_beef_request is not None: + _body_params = post_beef_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/beef', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_buffalo( + self, + post_buffalo_request: PostBuffaloRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostBuffalo200Response: + """Perform buffalo calculation + + Retrieve a simple JSON response + + :param post_buffalo_request: (required) + :type post_buffalo_request: PostBuffaloRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_buffalo_serialize( + post_buffalo_request=post_buffalo_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBuffalo200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_buffalo_with_http_info( + self, + post_buffalo_request: PostBuffaloRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostBuffalo200Response]: + """Perform buffalo calculation + + Retrieve a simple JSON response + + :param post_buffalo_request: (required) + :type post_buffalo_request: PostBuffaloRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_buffalo_serialize( + post_buffalo_request=post_buffalo_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBuffalo200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_buffalo_without_preload_content( + self, + post_buffalo_request: PostBuffaloRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform buffalo calculation + + Retrieve a simple JSON response + + :param post_buffalo_request: (required) + :type post_buffalo_request: PostBuffaloRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_buffalo_serialize( + post_buffalo_request=post_buffalo_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostBuffalo200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_buffalo_serialize( + self, + post_buffalo_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_buffalo_request is not None: + _body_params = post_buffalo_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/buffalo', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_cotton( + self, + post_cotton_request: PostCottonRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostCotton200Response: + """Perform cotton calculation + + Retrieve a simple JSON response + + :param post_cotton_request: (required) + :type post_cotton_request: PostCottonRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cotton_serialize( + post_cotton_request=post_cotton_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostCotton200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_cotton_with_http_info( + self, + post_cotton_request: PostCottonRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostCotton200Response]: + """Perform cotton calculation + + Retrieve a simple JSON response + + :param post_cotton_request: (required) + :type post_cotton_request: PostCottonRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cotton_serialize( + post_cotton_request=post_cotton_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostCotton200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_cotton_without_preload_content( + self, + post_cotton_request: PostCottonRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform cotton calculation + + Retrieve a simple JSON response + + :param post_cotton_request: (required) + :type post_cotton_request: PostCottonRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_cotton_serialize( + post_cotton_request=post_cotton_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostCotton200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_cotton_serialize( + self, + post_cotton_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_cotton_request is not None: + _body_params = post_cotton_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/cotton', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_dairy( + self, + post_dairy_request: PostDairyRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostDairy200Response: + """Perform dairy calculation + + Retrieve a simple JSON response + + :param post_dairy_request: (required) + :type post_dairy_request: PostDairyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_dairy_serialize( + post_dairy_request=post_dairy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDairy200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_dairy_with_http_info( + self, + post_dairy_request: PostDairyRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostDairy200Response]: + """Perform dairy calculation + + Retrieve a simple JSON response + + :param post_dairy_request: (required) + :type post_dairy_request: PostDairyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_dairy_serialize( + post_dairy_request=post_dairy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDairy200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_dairy_without_preload_content( + self, + post_dairy_request: PostDairyRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform dairy calculation + + Retrieve a simple JSON response + + :param post_dairy_request: (required) + :type post_dairy_request: PostDairyRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_dairy_serialize( + post_dairy_request=post_dairy_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDairy200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_dairy_serialize( + self, + post_dairy_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_dairy_request is not None: + _body_params = post_dairy_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/dairy', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_deer( + self, + post_deer_request: PostDeerRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostDeer200Response: + """Perform deer calculation + + Retrieve a simple JSON response + + :param post_deer_request: (required) + :type post_deer_request: PostDeerRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_deer_serialize( + post_deer_request=post_deer_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDeer200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_deer_with_http_info( + self, + post_deer_request: PostDeerRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostDeer200Response]: + """Perform deer calculation + + Retrieve a simple JSON response + + :param post_deer_request: (required) + :type post_deer_request: PostDeerRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_deer_serialize( + post_deer_request=post_deer_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDeer200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_deer_without_preload_content( + self, + post_deer_request: PostDeerRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform deer calculation + + Retrieve a simple JSON response + + :param post_deer_request: (required) + :type post_deer_request: PostDeerRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_deer_serialize( + post_deer_request=post_deer_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostDeer200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_deer_serialize( + self, + post_deer_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_deer_request is not None: + _body_params = post_deer_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/deer', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_feedlot( + self, + post_feedlot_request: PostFeedlotRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostFeedlot200Response: + """Perform feedlot calculation + + Retrieve a simple JSON response + + :param post_feedlot_request: (required) + :type post_feedlot_request: PostFeedlotRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_feedlot_serialize( + post_feedlot_request=post_feedlot_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostFeedlot200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_feedlot_with_http_info( + self, + post_feedlot_request: PostFeedlotRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostFeedlot200Response]: + """Perform feedlot calculation + + Retrieve a simple JSON response + + :param post_feedlot_request: (required) + :type post_feedlot_request: PostFeedlotRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_feedlot_serialize( + post_feedlot_request=post_feedlot_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostFeedlot200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_feedlot_without_preload_content( + self, + post_feedlot_request: PostFeedlotRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform feedlot calculation + + Retrieve a simple JSON response + + :param post_feedlot_request: (required) + :type post_feedlot_request: PostFeedlotRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_feedlot_serialize( + post_feedlot_request=post_feedlot_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostFeedlot200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_feedlot_serialize( + self, + post_feedlot_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_feedlot_request is not None: + _body_params = post_feedlot_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/feedlot', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_goat( + self, + post_goat_request: PostGoatRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostGoat200Response: + """Perform goat calculation + + Retrieve a simple JSON response + + :param post_goat_request: (required) + :type post_goat_request: PostGoatRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_goat_serialize( + post_goat_request=post_goat_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGoat200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_goat_with_http_info( + self, + post_goat_request: PostGoatRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostGoat200Response]: + """Perform goat calculation + + Retrieve a simple JSON response + + :param post_goat_request: (required) + :type post_goat_request: PostGoatRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_goat_serialize( + post_goat_request=post_goat_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGoat200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_goat_without_preload_content( + self, + post_goat_request: PostGoatRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform goat calculation + + Retrieve a simple JSON response + + :param post_goat_request: (required) + :type post_goat_request: PostGoatRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_goat_serialize( + post_goat_request=post_goat_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGoat200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_goat_serialize( + self, + post_goat_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_goat_request is not None: + _body_params = post_goat_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/goat', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_grains( + self, + post_grains_request: PostGrainsRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostGrains200Response: + """Perform grains calculation + + Retrieve a simple JSON response + + :param post_grains_request: (required) + :type post_grains_request: PostGrainsRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_grains_serialize( + post_grains_request=post_grains_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGrains200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_grains_with_http_info( + self, + post_grains_request: PostGrainsRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostGrains200Response]: + """Perform grains calculation + + Retrieve a simple JSON response + + :param post_grains_request: (required) + :type post_grains_request: PostGrainsRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_grains_serialize( + post_grains_request=post_grains_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGrains200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_grains_without_preload_content( + self, + post_grains_request: PostGrainsRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform grains calculation + + Retrieve a simple JSON response + + :param post_grains_request: (required) + :type post_grains_request: PostGrainsRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_grains_serialize( + post_grains_request=post_grains_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostGrains200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_grains_serialize( + self, + post_grains_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_grains_request is not None: + _body_params = post_grains_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/grains', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_horticulture( + self, + post_horticulture_request: PostHorticultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostHorticulture200Response: + """Perform horticulture calculation + + Retrieve a simple JSON response + + :param post_horticulture_request: (required) + :type post_horticulture_request: PostHorticultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_horticulture_serialize( + post_horticulture_request=post_horticulture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostHorticulture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_horticulture_with_http_info( + self, + post_horticulture_request: PostHorticultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostHorticulture200Response]: + """Perform horticulture calculation + + Retrieve a simple JSON response + + :param post_horticulture_request: (required) + :type post_horticulture_request: PostHorticultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_horticulture_serialize( + post_horticulture_request=post_horticulture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostHorticulture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_horticulture_without_preload_content( + self, + post_horticulture_request: PostHorticultureRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform horticulture calculation + + Retrieve a simple JSON response + + :param post_horticulture_request: (required) + :type post_horticulture_request: PostHorticultureRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_horticulture_serialize( + post_horticulture_request=post_horticulture_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostHorticulture200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_horticulture_serialize( + self, + post_horticulture_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_horticulture_request is not None: + _body_params = post_horticulture_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/horticulture', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_pork( + self, + post_pork_request: PostPorkRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostPork200Response: + """Perform pork calculation + + Retrieve a simple JSON response + + :param post_pork_request: (required) + :type post_pork_request: PostPorkRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_pork_serialize( + post_pork_request=post_pork_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPork200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_pork_with_http_info( + self, + post_pork_request: PostPorkRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostPork200Response]: + """Perform pork calculation + + Retrieve a simple JSON response + + :param post_pork_request: (required) + :type post_pork_request: PostPorkRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_pork_serialize( + post_pork_request=post_pork_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPork200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_pork_without_preload_content( + self, + post_pork_request: PostPorkRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform pork calculation + + Retrieve a simple JSON response + + :param post_pork_request: (required) + :type post_pork_request: PostPorkRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_pork_serialize( + post_pork_request=post_pork_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPork200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_pork_serialize( + self, + post_pork_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_pork_request is not None: + _body_params = post_pork_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/pork', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_poultry( + self, + post_poultry_request: PostPoultryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostPoultry200Response: + """Perform poultry calculation + + Retrieve a simple JSON response + + :param post_poultry_request: (required) + :type post_poultry_request: PostPoultryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_poultry_serialize( + post_poultry_request=post_poultry_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPoultry200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_poultry_with_http_info( + self, + post_poultry_request: PostPoultryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostPoultry200Response]: + """Perform poultry calculation + + Retrieve a simple JSON response + + :param post_poultry_request: (required) + :type post_poultry_request: PostPoultryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_poultry_serialize( + post_poultry_request=post_poultry_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPoultry200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_poultry_without_preload_content( + self, + post_poultry_request: PostPoultryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform poultry calculation + + Retrieve a simple JSON response + + :param post_poultry_request: (required) + :type post_poultry_request: PostPoultryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_poultry_serialize( + post_poultry_request=post_poultry_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostPoultry200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_poultry_serialize( + self, + post_poultry_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_poultry_request is not None: + _body_params = post_poultry_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/poultry', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_processing( + self, + post_processing_request: PostProcessingRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostProcessing200Response: + """Perform processing calculation + + Retrieve a simple JSON response + + :param post_processing_request: (required) + :type post_processing_request: PostProcessingRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_processing_serialize( + post_processing_request=post_processing_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostProcessing200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_processing_with_http_info( + self, + post_processing_request: PostProcessingRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostProcessing200Response]: + """Perform processing calculation + + Retrieve a simple JSON response + + :param post_processing_request: (required) + :type post_processing_request: PostProcessingRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_processing_serialize( + post_processing_request=post_processing_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostProcessing200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_processing_without_preload_content( + self, + post_processing_request: PostProcessingRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform processing calculation + + Retrieve a simple JSON response + + :param post_processing_request: (required) + :type post_processing_request: PostProcessingRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_processing_serialize( + post_processing_request=post_processing_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostProcessing200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_processing_serialize( + self, + post_processing_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_processing_request is not None: + _body_params = post_processing_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/processing', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_rice( + self, + post_rice_request: PostRiceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostRice200Response: + """Perform rice calculation + + Retrieve a simple JSON response + + :param post_rice_request: (required) + :type post_rice_request: PostRiceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_rice_serialize( + post_rice_request=post_rice_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostRice200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_rice_with_http_info( + self, + post_rice_request: PostRiceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostRice200Response]: + """Perform rice calculation + + Retrieve a simple JSON response + + :param post_rice_request: (required) + :type post_rice_request: PostRiceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_rice_serialize( + post_rice_request=post_rice_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostRice200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_rice_without_preload_content( + self, + post_rice_request: PostRiceRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform rice calculation + + Retrieve a simple JSON response + + :param post_rice_request: (required) + :type post_rice_request: PostRiceRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_rice_serialize( + post_rice_request=post_rice_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostRice200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_rice_serialize( + self, + post_rice_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_rice_request is not None: + _body_params = post_rice_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/rice', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_sheep( + self, + post_sheep_request: PostSheepRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostSheep200Response: + """Perform sheep calculation + + Retrieve a simple JSON response + + :param post_sheep_request: (required) + :type post_sheep_request: PostSheepRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheep_serialize( + post_sheep_request=post_sheep_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheep200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_sheep_with_http_info( + self, + post_sheep_request: PostSheepRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostSheep200Response]: + """Perform sheep calculation + + Retrieve a simple JSON response + + :param post_sheep_request: (required) + :type post_sheep_request: PostSheepRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheep_serialize( + post_sheep_request=post_sheep_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheep200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_sheep_without_preload_content( + self, + post_sheep_request: PostSheepRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform sheep calculation + + Retrieve a simple JSON response + + :param post_sheep_request: (required) + :type post_sheep_request: PostSheepRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheep_serialize( + post_sheep_request=post_sheep_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheep200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_sheep_serialize( + self, + post_sheep_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_sheep_request is not None: + _body_params = post_sheep_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/sheep', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_sheepbeef( + self, + post_sheepbeef_request: PostSheepbeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostSheepbeef200Response: + """Perform sheepbeef calculation + + Retrieve a simple JSON response + + :param post_sheepbeef_request: (required) + :type post_sheepbeef_request: PostSheepbeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheepbeef_serialize( + post_sheepbeef_request=post_sheepbeef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheepbeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_sheepbeef_with_http_info( + self, + post_sheepbeef_request: PostSheepbeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostSheepbeef200Response]: + """Perform sheepbeef calculation + + Retrieve a simple JSON response + + :param post_sheepbeef_request: (required) + :type post_sheepbeef_request: PostSheepbeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheepbeef_serialize( + post_sheepbeef_request=post_sheepbeef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheepbeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_sheepbeef_without_preload_content( + self, + post_sheepbeef_request: PostSheepbeefRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform sheepbeef calculation + + Retrieve a simple JSON response + + :param post_sheepbeef_request: (required) + :type post_sheepbeef_request: PostSheepbeefRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sheepbeef_serialize( + post_sheepbeef_request=post_sheepbeef_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSheepbeef200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_sheepbeef_serialize( + self, + post_sheepbeef_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_sheepbeef_request is not None: + _body_params = post_sheepbeef_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/sheepbeef', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_sugar( + self, + post_sugar_request: PostSugarRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostSugar200Response: + """Perform sugar calculation + + Retrieve a simple JSON response + + :param post_sugar_request: (required) + :type post_sugar_request: PostSugarRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sugar_serialize( + post_sugar_request=post_sugar_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSugar200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_sugar_with_http_info( + self, + post_sugar_request: PostSugarRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostSugar200Response]: + """Perform sugar calculation + + Retrieve a simple JSON response + + :param post_sugar_request: (required) + :type post_sugar_request: PostSugarRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sugar_serialize( + post_sugar_request=post_sugar_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSugar200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_sugar_without_preload_content( + self, + post_sugar_request: PostSugarRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform sugar calculation + + Retrieve a simple JSON response + + :param post_sugar_request: (required) + :type post_sugar_request: PostSugarRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_sugar_serialize( + post_sugar_request=post_sugar_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostSugar200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_sugar_serialize( + self, + post_sugar_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_sugar_request is not None: + _body_params = post_sugar_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/sugar', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_vineyard( + self, + post_vineyard_request: PostVineyardRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostVineyard200Response: + """Perform vineyard calculation + + Retrieve a simple JSON response + + :param post_vineyard_request: (required) + :type post_vineyard_request: PostVineyardRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_vineyard_serialize( + post_vineyard_request=post_vineyard_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostVineyard200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_vineyard_with_http_info( + self, + post_vineyard_request: PostVineyardRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostVineyard200Response]: + """Perform vineyard calculation + + Retrieve a simple JSON response + + :param post_vineyard_request: (required) + :type post_vineyard_request: PostVineyardRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_vineyard_serialize( + post_vineyard_request=post_vineyard_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostVineyard200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_vineyard_without_preload_content( + self, + post_vineyard_request: PostVineyardRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform vineyard calculation + + Retrieve a simple JSON response + + :param post_vineyard_request: (required) + :type post_vineyard_request: PostVineyardRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_vineyard_serialize( + post_vineyard_request=post_vineyard_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostVineyard200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_vineyard_serialize( + self, + post_vineyard_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_vineyard_request is not None: + _body_params = post_vineyard_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/vineyard', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_wildcatchfishery( + self, + post_wildcatchfishery_request: PostWildcatchfisheryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostWildcatchfishery200Response: + """Perform wildcatchfishery calculation + + Retrieve a simple JSON response + + :param post_wildcatchfishery_request: (required) + :type post_wildcatchfishery_request: PostWildcatchfisheryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildcatchfishery_serialize( + post_wildcatchfishery_request=post_wildcatchfishery_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildcatchfishery200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_wildcatchfishery_with_http_info( + self, + post_wildcatchfishery_request: PostWildcatchfisheryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostWildcatchfishery200Response]: + """Perform wildcatchfishery calculation + + Retrieve a simple JSON response + + :param post_wildcatchfishery_request: (required) + :type post_wildcatchfishery_request: PostWildcatchfisheryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildcatchfishery_serialize( + post_wildcatchfishery_request=post_wildcatchfishery_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildcatchfishery200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_wildcatchfishery_without_preload_content( + self, + post_wildcatchfishery_request: PostWildcatchfisheryRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform wildcatchfishery calculation + + Retrieve a simple JSON response + + :param post_wildcatchfishery_request: (required) + :type post_wildcatchfishery_request: PostWildcatchfisheryRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildcatchfishery_serialize( + post_wildcatchfishery_request=post_wildcatchfishery_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildcatchfishery200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_wildcatchfishery_serialize( + self, + post_wildcatchfishery_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_wildcatchfishery_request is not None: + _body_params = post_wildcatchfishery_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/wildcatchfishery', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def post_wildseafisheries( + self, + post_wildseafisheries_request: PostWildseafisheriesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PostWildseafisheries200Response: + """Perform wildseafisheries calculation + + Retrieve a simple JSON response + + :param post_wildseafisheries_request: (required) + :type post_wildseafisheries_request: PostWildseafisheriesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildseafisheries_serialize( + post_wildseafisheries_request=post_wildseafisheries_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildseafisheries200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def post_wildseafisheries_with_http_info( + self, + post_wildseafisheries_request: PostWildseafisheriesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PostWildseafisheries200Response]: + """Perform wildseafisheries calculation + + Retrieve a simple JSON response + + :param post_wildseafisheries_request: (required) + :type post_wildseafisheries_request: PostWildseafisheriesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildseafisheries_serialize( + post_wildseafisheries_request=post_wildseafisheries_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildseafisheries200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def post_wildseafisheries_without_preload_content( + self, + post_wildseafisheries_request: PostWildseafisheriesRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Perform wildseafisheries calculation + + Retrieve a simple JSON response + + :param post_wildseafisheries_request: (required) + :type post_wildseafisheries_request: PostWildseafisheriesRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._post_wildseafisheries_serialize( + post_wildseafisheries_request=post_wildseafisheries_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PostWildseafisheries200Response", + '401': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _post_wildseafisheries_serialize( + self, + post_wildseafisheries_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if post_wildseafisheries_request is not None: + _body_params = post_wildseafisheries_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/wildseafisheries', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/examples/python-api-client/api-client/openapi_client/api_client.py b/examples/python-api-client/api-client/openapi_client/api_client.py new file mode 100644 index 00000000..50a16097 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/api_client.py @@ -0,0 +1,802 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import datetime +from dateutil.parser import parse +from enum import Enum +import decimal +import json +import mimetypes +import os +import re +import tempfile + +from urllib.parse import quote +from typing import Tuple, Optional, List, Dict, Union +from pydantic import SecretStr + +from openapi_client.configuration import Configuration +from openapi_client.api_response import ApiResponse, T as ApiResponseT +import openapi_client.models +from openapi_client import rest +from openapi_client.exceptions import ( + ApiValueError, + ApiException, + BadRequestException, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int, # TODO remove as only py3 is supported? + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'decimal': decimal.Decimal, + 'object': object, + } + _pool = None + + def __init__( + self, + configuration=None, + header_name=None, + header_value=None, + cookie=None + ) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + pass + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None + ) -> RequestSerialized: + + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict( + self.parameters_to_tuples(header_params,collection_formats) + ) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples( + path_params, + collection_formats + ) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples( + post_params, + collection_formats + ) + if files: + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, + query_params, + auth_settings, + resource_path, + method, + body, + request_auth=_request_auth + ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None or self.configuration.ignore_operation_servers: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query( + query_params, + collection_formats + ) + url += "?" + url_query + + return method, url, header_params, body, post_params + + + def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + + try: + # perform request and return response + response_data = self.rest_client.request( + method, url, + headers=header_params, + body=body, post_params=post_params, + _request_timeout=_request_timeout + ) + + except ApiException as e: + raise e + + return response_data + + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]]=None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ + + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg + + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + # deserialize response data + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) + + return ApiResponse( + status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data + ) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is decimal.Decimal return string representation. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [ + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ] + elif isinstance(obj, tuple): + return tuple( + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) + + elif isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ + + if isinstance(obj_dict, list): + # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() + return self.sanitize_for_serialization(obj_dict) + + return { + key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items() + } + + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + :param content_type: content type of response. + + :return: deserialized object. + """ + + # fetch data from response object + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE): + data = response_text + else: + raise ApiException( + status=0, + reason="Unsupported content type: {0}".format(content_type) + ) + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith('List['): + m = re.match(r'List\[(.*)]', klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + m = re.match(r'Dict\[([^,]*), (.*)]', klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(openapi_client.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + elif klass == decimal.Decimal: + return decimal.Decimal(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) + else: + return self.__deserialize_model(data, klass) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, quote(str(value))) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v)) + ) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters( + self, + files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], + ): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + for k, v in files.items(): + if isinstance(v, str): + with open(v, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + elif isinstance(v, tuple): + filename, filedata = v + elif isinstance(v, list): + for file_param in v: + params.extend(self.files_parameters({k: file_param})) + continue + else: + raise ValueError("Unsupported file value") + mimetype = ( + mimetypes.guess_type(filename)[0] + or 'application/octet-stream' + ) + params.append( + tuple([k, tuple([filename, filedata, mimetype])]) + ) + return params + + def select_header_accept(self, accepts: List[str]) -> Optional[str]: + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return None + + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, + headers, + queries, + auth_settings, + resource_path, + method, + body, + request_auth=None + ) -> None: + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + request_auth + ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + auth_setting + ) + + def _apply_auth_params( + self, + headers, + queries, + resource_path, + method, + body, + auth_setting + ) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + queries.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + handle file downloading + save response body into a tmp file and return the instance + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + m = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition + ) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as `{1}`" + .format(data, klass) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/examples/python-api-client/api-client/openapi_client/api_response.py b/examples/python-api-client/api-client/openapi_client/api_response.py new file mode 100644 index 00000000..9bc7c11f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/api_response.py @@ -0,0 +1,21 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel + +T = TypeVar("T") + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = { + "arbitrary_types_allowed": True + } diff --git a/examples/python-api-client/api-client/openapi_client/configuration.py b/examples/python-api-client/api-client/openapi_client/configuration.py new file mode 100644 index 00000000..c16049b5 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/configuration.py @@ -0,0 +1,577 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import copy +import http.client as httplib +import logging +from logging import FileHandler +import multiprocessing +import sys +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union +from typing_extensions import NotRequired, Self + +import urllib3 + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + :param retries: Number of retries for API requests. + :param ca_cert_data: verify the peer using concatenated CA certificate data + in PEM (str) or DER (bytes) format. + :param cert_file: client certificate file + :param key_file: client key file + + """ + + _default: ClassVar[Optional[Self]] = None + + def __init__( + self, + host: Optional[str]=None, + api_key: Optional[Dict[str, str]]=None, + api_key_prefix: Optional[Dict[str, str]]=None, + username: Optional[str]=None, + password: Optional[str]=None, + access_token: Optional[str]=None, + server_index: Optional[int]=None, + server_variables: Optional[ServerVariablesT]=None, + server_operation_index: Optional[Dict[int, int]]=None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, + ignore_operation_servers: bool=False, + ssl_ca_cert: Optional[str]=None, + retries: Optional[int] = None, + ca_cert_data: Optional[Union[str, bytes]] = None, + *, + debug: Optional[bool] = None, + cert_file: Optional[str]=None, + key_file: Optional[str]=None, + ) -> None: + """Constructor + """ + self._base_path = "https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("openapi_client") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler: Optional[FileHandler] = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + if debug is not None: + self.debug = debug + else: + self.__debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.ca_cert_data = ca_cert_data + """Set this to verify the peer using PEM (str) or DER (bytes) + certificate data. + """ + self.cert_file = cert_file + """client certificate file + """ + self.key_file = key_file + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy: Optional[str] = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = retries + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name: str, value: Any) -> None: + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default: Optional[Self]) -> None: + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls) -> Self: + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls) -> Self: + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = cls() + return cls._default + + @property + def logger_file(self) -> Optional[str]: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value: Optional[str]) -> None: + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self) -> bool: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value: bool) -> None: + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self) -> str: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value: str) -> None: + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]: + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + return None + + def get_basic_auth_token(self) -> Optional[str]: + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self)-> AuthSettings: + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth: AuthSettings = {} + return auth + + def to_debug_report(self) -> str: + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 3.0.0\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self) -> List[HostSetting]: + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "https://emissionscalculator-mtls.development.aiaapi.com/calculator/3.0.0", + 'description': "Production Server", + } + ] + + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT]=None, + servers: Optional[List[HostSetting]]=None, + ) -> str: + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self) -> str: + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value: str) -> None: + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/examples/python-api-client/api-client/openapi_client/exceptions.py b/examples/python-api-client/api-client/openapi_client/exceptions.py new file mode 100644 index 00000000..b26c0c4e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/exceptions.py @@ -0,0 +1,217 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from typing import Any, Optional +from typing_extensions import Self + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None) -> None: + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + + if http_resp: + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass + self.headers = http_resp.getheaders() + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + # Added new conditions for 409 and 422 + if http_resp.status == 409: + raise ConflictException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 422: + raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) + + return error_message + + +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + +class ConflictException(ApiException): + """Exception for HTTP 409 Conflict.""" + pass + + +class UnprocessableEntityException(ApiException): + """Exception for HTTP 422 Unprocessable Entity.""" + pass + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/examples/python-api-client/api-client/openapi_client/models/__init__.py b/examples/python-api-client/api-client/openapi_client/models/__init__.py new file mode 100644 index 00000000..5699ffce --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/__init__.py @@ -0,0 +1,308 @@ +# coding: utf-8 + +# flake8: noqa +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package +from openapi_client.models.post_aquaculture200_response import PostAquaculture200Response +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_intensities import PostAquaculture200ResponseIntensities +from openapi_client.models.post_aquaculture200_response_intermediate_inner import PostAquaculture200ResponseIntermediateInner +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope1 import PostAquaculture200ResponseScope1 +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 +from openapi_client.models.post_aquaculture_request import PostAquacultureRequest +from openapi_client.models.post_aquaculture_request_enterprises_inner import PostAquacultureRequestEnterprisesInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_bait_inner import PostAquacultureRequestEnterprisesInnerBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_custom_bait_inner import PostAquacultureRequestEnterprisesInnerCustomBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_inbound_freight_inner import PostAquacultureRequestEnterprisesInnerInboundFreightInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_refrigerants_inner import PostAquacultureRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste +from openapi_client.models.post_beef200_response import PostBeef200Response +from openapi_client.models.post_beef200_response_intermediate_inner import PostBeef200ResponseIntermediateInner +from openapi_client.models.post_beef200_response_intermediate_inner_intensities import PostBeef200ResponseIntermediateInnerIntensities +from openapi_client.models.post_beef200_response_net import PostBeef200ResponseNet +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_beef_request import PostBeefRequest +from openapi_client.models.post_beef_request_beef_inner import PostBeefRequestBeefInner +from openapi_client.models.post_beef_request_beef_inner_classes import PostBeefRequestBeefInnerClasses +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1 import PostBeefRequestBeefInnerClassesBullsGt1 +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_traded import PostBeefRequestBeefInnerClassesBullsGt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2 import PostBeefRequestBeefInnerClassesCowsGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2_traded import PostBeefRequestBeefInnerClassesCowsGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2 import PostBeefRequestBeefInnerClassesHeifers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2_traded import PostBeefRequestBeefInnerClassesHeifers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2 import PostBeefRequestBeefInnerClassesHeifersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2_traded import PostBeefRequestBeefInnerClassesHeifersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1 import PostBeefRequestBeefInnerClassesHeifersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1_traded import PostBeefRequestBeefInnerClassesHeifersLt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2 import PostBeefRequestBeefInnerClassesSteers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2_traded import PostBeefRequestBeefInnerClassesSteers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2 import PostBeefRequestBeefInnerClassesSteersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2_traded import PostBeefRequestBeefInnerClassesSteersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1 import PostBeefRequestBeefInnerClassesSteersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1_traded import PostBeefRequestBeefInnerClassesSteersLt1Traded +from openapi_client.models.post_beef_request_beef_inner_cows_calving import PostBeefRequestBeefInnerCowsCalving +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_beef_request_beef_inner_fertiliser_other_fertilisers_inner import PostBeefRequestBeefInnerFertiliserOtherFertilisersInner +from openapi_client.models.post_beef_request_beef_inner_mineral_supplementation import PostBeefRequestBeefInnerMineralSupplementation +from openapi_client.models.post_beef_request_burning_inner import PostBeefRequestBurningInner +from openapi_client.models.post_beef_request_burning_inner_burning import PostBeefRequestBurningInnerBurning +from openapi_client.models.post_beef_request_vegetation_inner import PostBeefRequestVegetationInner +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from openapi_client.models.post_buffalo200_response import PostBuffalo200Response +from openapi_client.models.post_buffalo200_response_intensities import PostBuffalo200ResponseIntensities +from openapi_client.models.post_buffalo200_response_intermediate_inner import PostBuffalo200ResponseIntermediateInner +from openapi_client.models.post_buffalo200_response_net import PostBuffalo200ResponseNet +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 +from openapi_client.models.post_buffalo_request import PostBuffaloRequest +from openapi_client.models.post_buffalo_request_buffalos_inner import PostBuffaloRequestBuffalosInner +from openapi_client.models.post_buffalo_request_buffalos_inner_classes import PostBuffaloRequestBuffalosInnerClasses +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls import PostBuffaloRequestBuffalosInnerClassesBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_calfs import PostBuffaloRequestBuffalosInnerClassesCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_cows import PostBuffaloRequestBuffalosInnerClassesCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_steers import PostBuffaloRequestBuffalosInnerClassesSteers +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_bulls import PostBuffaloRequestBuffalosInnerClassesTradeBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_calfs import PostBuffaloRequestBuffalosInnerClassesTradeCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_cows import PostBuffaloRequestBuffalosInnerClassesTradeCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_steers import PostBuffaloRequestBuffalosInnerClassesTradeSteers +from openapi_client.models.post_buffalo_request_buffalos_inner_cows_calving import PostBuffaloRequestBuffalosInnerCowsCalving +from openapi_client.models.post_buffalo_request_buffalos_inner_seasonal_calving import PostBuffaloRequestBuffalosInnerSeasonalCalving +from openapi_client.models.post_buffalo_request_vegetation_inner import PostBuffaloRequestVegetationInner +from openapi_client.models.post_cotton200_response import PostCotton200Response +from openapi_client.models.post_cotton200_response_intermediate_inner import PostCotton200ResponseIntermediateInner +from openapi_client.models.post_cotton200_response_intermediate_inner_intensities import PostCotton200ResponseIntermediateInnerIntensities +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_cotton_request import PostCottonRequest +from openapi_client.models.post_cotton_request_crops_inner import PostCottonRequestCropsInner +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from openapi_client.models.post_dairy200_response import PostDairy200Response +from openapi_client.models.post_dairy200_response_intensities import PostDairy200ResponseIntensities +from openapi_client.models.post_dairy200_response_intermediate_inner import PostDairy200ResponseIntermediateInner +from openapi_client.models.post_dairy200_response_net import PostDairy200ResponseNet +from openapi_client.models.post_dairy200_response_scope1 import PostDairy200ResponseScope1 +from openapi_client.models.post_dairy200_response_scope3 import PostDairy200ResponseScope3 +from openapi_client.models.post_dairy_request import PostDairyRequest +from openapi_client.models.post_dairy_request_dairy_inner import PostDairyRequestDairyInner +from openapi_client.models.post_dairy_request_dairy_inner_areas import PostDairyRequestDairyInnerAreas +from openapi_client.models.post_dairy_request_dairy_inner_classes import PostDairyRequestDairyInnerClasses +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_gt1 import PostDairyRequestDairyInnerClassesDairyBullsGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_lt1 import PostDairyRequestDairyInnerClassesDairyBullsLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_gt1 import PostDairyRequestDairyInnerClassesHeifersGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_lt1 import PostDairyRequestDairyInnerClassesHeifersLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows import PostDairyRequestDairyInnerClassesMilkingCows +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from openapi_client.models.post_dairy_request_dairy_inner_manure_management_milking_cows import PostDairyRequestDairyInnerManureManagementMilkingCows +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser import PostDairyRequestDairyInnerSeasonalFertiliser +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser_autumn import PostDairyRequestDairyInnerSeasonalFertiliserAutumn +from openapi_client.models.post_dairy_request_vegetation_inner import PostDairyRequestVegetationInner +from openapi_client.models.post_deer200_response import PostDeer200Response +from openapi_client.models.post_deer200_response_intensities import PostDeer200ResponseIntensities +from openapi_client.models.post_deer200_response_intermediate_inner import PostDeer200ResponseIntermediateInner +from openapi_client.models.post_deer200_response_net import PostDeer200ResponseNet +from openapi_client.models.post_deer_request import PostDeerRequest +from openapi_client.models.post_deer_request_deers_inner import PostDeerRequestDeersInner +from openapi_client.models.post_deer_request_deers_inner_classes import PostDeerRequestDeersInnerClasses +from openapi_client.models.post_deer_request_deers_inner_classes_breeding_does import PostDeerRequestDeersInnerClassesBreedingDoes +from openapi_client.models.post_deer_request_deers_inner_classes_bucks import PostDeerRequestDeersInnerClassesBucks +from openapi_client.models.post_deer_request_deers_inner_classes_fawn import PostDeerRequestDeersInnerClassesFawn +from openapi_client.models.post_deer_request_deers_inner_classes_other_does import PostDeerRequestDeersInnerClassesOtherDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_bucks import PostDeerRequestDeersInnerClassesTradeBucks +from openapi_client.models.post_deer_request_deers_inner_classes_trade_does import PostDeerRequestDeersInnerClassesTradeDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_fawn import PostDeerRequestDeersInnerClassesTradeFawn +from openapi_client.models.post_deer_request_deers_inner_classes_trade_other_does import PostDeerRequestDeersInnerClassesTradeOtherDoes +from openapi_client.models.post_deer_request_deers_inner_does_fawning import PostDeerRequestDeersInnerDoesFawning +from openapi_client.models.post_deer_request_deers_inner_seasonal_fawning import PostDeerRequestDeersInnerSeasonalFawning +from openapi_client.models.post_deer_request_vegetation_inner import PostDeerRequestVegetationInner +from openapi_client.models.post_feedlot200_response import PostFeedlot200Response +from openapi_client.models.post_feedlot200_response_intermediate_inner import PostFeedlot200ResponseIntermediateInner +from openapi_client.models.post_feedlot200_response_intermediate_inner_intensities import PostFeedlot200ResponseIntermediateInnerIntensities +from openapi_client.models.post_feedlot200_response_intermediate_inner_net import PostFeedlot200ResponseIntermediateInnerNet +from openapi_client.models.post_feedlot200_response_scope1 import PostFeedlot200ResponseScope1 +from openapi_client.models.post_feedlot200_response_scope3 import PostFeedlot200ResponseScope3 +from openapi_client.models.post_feedlot_request import PostFeedlotRequest +from openapi_client.models.post_feedlot_request_feedlots_inner import PostFeedlotRequestFeedlotsInner +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner import PostFeedlotRequestFeedlotsInnerGroupsInner +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner_stays_inner import PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases import PostFeedlotRequestFeedlotsInnerPurchases +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner +from openapi_client.models.post_feedlot_request_feedlots_inner_sales import PostFeedlotRequestFeedlotsInnerSales +from openapi_client.models.post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner +from openapi_client.models.post_feedlot_request_vegetation_inner import PostFeedlotRequestVegetationInner +from openapi_client.models.post_goat200_response import PostGoat200Response +from openapi_client.models.post_goat200_response_intensities import PostGoat200ResponseIntensities +from openapi_client.models.post_goat200_response_intermediate_inner import PostGoat200ResponseIntermediateInner +from openapi_client.models.post_goat200_response_net import PostGoat200ResponseNet +from openapi_client.models.post_goat_request import PostGoatRequest +from openapi_client.models.post_goat_request_goats_inner import PostGoatRequestGoatsInner +from openapi_client.models.post_goat_request_goats_inner_classes import PostGoatRequestGoatsInnerClasses +from openapi_client.models.post_goat_request_goats_inner_classes_breeding_does_nannies import PostGoatRequestGoatsInnerClassesBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_bucks_billy import PostGoatRequestGoatsInnerClassesBucksBilly +from openapi_client.models.post_goat_request_goats_inner_classes_kids import PostGoatRequestGoatsInnerClassesKids +from openapi_client.models.post_goat_request_goats_inner_classes_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_other_does_culled_females import PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_bucks import PostGoatRequestGoatsInnerClassesTradeBucks +from openapi_client.models.post_goat_request_goats_inner_classes_trade_does import PostGoatRequestGoatsInnerClassesTradeDoes +from openapi_client.models.post_goat_request_goats_inner_classes_trade_kids import PostGoatRequestGoatsInnerClassesTradeKids +from openapi_client.models.post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_other_does_culled_females import PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_wethers import PostGoatRequestGoatsInnerClassesTradeWethers +from openapi_client.models.post_goat_request_goats_inner_classes_wethers import PostGoatRequestGoatsInnerClassesWethers +from openapi_client.models.post_goat_request_vegetation_inner import PostGoatRequestVegetationInner +from openapi_client.models.post_grains200_response import PostGrains200Response +from openapi_client.models.post_grains200_response_intermediate_inner import PostGrains200ResponseIntermediateInner +from openapi_client.models.post_grains200_response_intermediate_inner_intensities_with_sequestration import PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_grains_request import PostGrainsRequest +from openapi_client.models.post_grains_request_crops_inner import PostGrainsRequestCropsInner +from openapi_client.models.post_horticulture200_response import PostHorticulture200Response +from openapi_client.models.post_horticulture200_response_intermediate_inner import PostHorticulture200ResponseIntermediateInner +from openapi_client.models.post_horticulture200_response_intermediate_inner_intensities_with_sequestration import PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_horticulture200_response_scope1 import PostHorticulture200ResponseScope1 +from openapi_client.models.post_horticulture_request import PostHorticultureRequest +from openapi_client.models.post_horticulture_request_crops_inner import PostHorticultureRequestCropsInner +from openapi_client.models.post_horticulture_request_crops_inner_refrigerants_inner import PostHorticultureRequestCropsInnerRefrigerantsInner +from openapi_client.models.post_pork200_response import PostPork200Response +from openapi_client.models.post_pork200_response_intensities import PostPork200ResponseIntensities +from openapi_client.models.post_pork200_response_intermediate_inner import PostPork200ResponseIntermediateInner +from openapi_client.models.post_pork200_response_net import PostPork200ResponseNet +from openapi_client.models.post_pork200_response_scope1 import PostPork200ResponseScope1 +from openapi_client.models.post_pork200_response_scope3 import PostPork200ResponseScope3 +from openapi_client.models.post_pork_request import PostPorkRequest +from openapi_client.models.post_pork_request_pork_inner import PostPorkRequestPorkInner +from openapi_client.models.post_pork_request_pork_inner_classes import PostPorkRequestPorkInnerClasses +from openapi_client.models.post_pork_request_pork_inner_classes_boars import PostPorkRequestPorkInnerClassesBoars +from openapi_client.models.post_pork_request_pork_inner_classes_gilts import PostPorkRequestPorkInnerClassesGilts +from openapi_client.models.post_pork_request_pork_inner_classes_growers import PostPorkRequestPorkInnerClassesGrowers +from openapi_client.models.post_pork_request_pork_inner_classes_slaughter_pigs import PostPorkRequestPorkInnerClassesSlaughterPigs +from openapi_client.models.post_pork_request_pork_inner_classes_sows import PostPorkRequestPorkInnerClassesSows +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure_spring import PostPorkRequestPorkInnerClassesSowsManureSpring +from openapi_client.models.post_pork_request_pork_inner_classes_suckers import PostPorkRequestPorkInnerClassesSuckers +from openapi_client.models.post_pork_request_pork_inner_classes_weaners import PostPorkRequestPorkInnerClassesWeaners +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner import PostPorkRequestPorkInnerFeedProductsInner +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner_ingredients import PostPorkRequestPorkInnerFeedProductsInnerIngredients +from openapi_client.models.post_pork_request_vegetation_inner import PostPorkRequestVegetationInner +from openapi_client.models.post_poultry200_response import PostPoultry200Response +from openapi_client.models.post_poultry200_response_intensities import PostPoultry200ResponseIntensities +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner import PostPoultry200ResponseIntermediateBroilersInner +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner_intensities import PostPoultry200ResponseIntermediateBroilersInnerIntensities +from openapi_client.models.post_poultry200_response_intermediate_layers_inner import PostPoultry200ResponseIntermediateLayersInner +from openapi_client.models.post_poultry200_response_intermediate_layers_inner_intensities import PostPoultry200ResponseIntermediateLayersInnerIntensities +from openapi_client.models.post_poultry200_response_net import PostPoultry200ResponseNet +from openapi_client.models.post_poultry200_response_scope1 import PostPoultry200ResponseScope1 +from openapi_client.models.post_poultry200_response_scope3 import PostPoultry200ResponseScope3 +from openapi_client.models.post_poultry_request import PostPoultryRequest +from openapi_client.models.post_poultry_request_broilers_inner import PostPoultryRequestBroilersInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner import PostPoultryRequestBroilersInnerGroupsInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner import PostPoultryRequestBroilersInnerGroupsInnerFeedInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients import PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers import PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_growers_purchases import PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_layers_purchases import PostPoultryRequestBroilersInnerMeatChickenLayersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_other_purchases import PostPoultryRequestBroilersInnerMeatOtherPurchases +from openapi_client.models.post_poultry_request_broilers_inner_sales_inner import PostPoultryRequestBroilersInnerSalesInner +from openapi_client.models.post_poultry_request_layers_inner import PostPoultryRequestLayersInner +from openapi_client.models.post_poultry_request_layers_inner_layers import PostPoultryRequestLayersInnerLayers +from openapi_client.models.post_poultry_request_layers_inner_layers_egg_sale import PostPoultryRequestLayersInnerLayersEggSale +from openapi_client.models.post_poultry_request_layers_inner_layers_purchases import PostPoultryRequestLayersInnerLayersPurchases +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers import PostPoultryRequestLayersInnerMeatChickenLayers +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers_egg_sale import PostPoultryRequestLayersInnerMeatChickenLayersEggSale +from openapi_client.models.post_poultry_request_vegetation_inner import PostPoultryRequestVegetationInner +from openapi_client.models.post_processing200_response import PostProcessing200Response +from openapi_client.models.post_processing200_response_intensities_inner import PostProcessing200ResponseIntensitiesInner +from openapi_client.models.post_processing200_response_intermediate_inner import PostProcessing200ResponseIntermediateInner +from openapi_client.models.post_processing200_response_net import PostProcessing200ResponseNet +from openapi_client.models.post_processing200_response_scope1 import PostProcessing200ResponseScope1 +from openapi_client.models.post_processing200_response_scope3 import PostProcessing200ResponseScope3 +from openapi_client.models.post_processing_request import PostProcessingRequest +from openapi_client.models.post_processing_request_products_inner import PostProcessingRequestProductsInner +from openapi_client.models.post_processing_request_products_inner_product import PostProcessingRequestProductsInnerProduct +from openapi_client.models.post_rice200_response import PostRice200Response +from openapi_client.models.post_rice200_response_intensities import PostRice200ResponseIntensities +from openapi_client.models.post_rice200_response_intermediate_inner import PostRice200ResponseIntermediateInner +from openapi_client.models.post_rice200_response_intermediate_inner_intensities import PostRice200ResponseIntermediateInnerIntensities +from openapi_client.models.post_rice200_response_scope1 import PostRice200ResponseScope1 +from openapi_client.models.post_rice_request import PostRiceRequest +from openapi_client.models.post_rice_request_crops_inner import PostRiceRequestCropsInner +from openapi_client.models.post_sheep200_response import PostSheep200Response +from openapi_client.models.post_sheep200_response_intermediate_inner import PostSheep200ResponseIntermediateInner +from openapi_client.models.post_sheep200_response_intermediate_inner_intensities import PostSheep200ResponseIntermediateInnerIntensities +from openapi_client.models.post_sheep200_response_net import PostSheep200ResponseNet +from openapi_client.models.post_sheep_request import PostSheepRequest +from openapi_client.models.post_sheep_request_sheep_inner import PostSheepRequestSheepInner +from openapi_client.models.post_sheep_request_sheep_inner_classes import PostSheepRequestSheepInnerClasses +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams import PostSheepRequestSheepInnerClassesRams +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams_autumn import PostSheepRequestSheepInnerClassesRamsAutumn +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_ewes import PostSheepRequestSheepInnerClassesTradeEwes +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets import PostSheepRequestSheepInnerClassesTradeLambsAndHoggets +from openapi_client.models.post_sheep_request_sheep_inner_ewes_lambing import PostSheepRequestSheepInnerEwesLambing +from openapi_client.models.post_sheep_request_sheep_inner_seasonal_lambing import PostSheepRequestSheepInnerSeasonalLambing +from openapi_client.models.post_sheep_request_vegetation_inner import PostSheepRequestVegetationInner +from openapi_client.models.post_sheepbeef200_response import PostSheepbeef200Response +from openapi_client.models.post_sheepbeef200_response_intensities import PostSheepbeef200ResponseIntensities +from openapi_client.models.post_sheepbeef200_response_intermediate import PostSheepbeef200ResponseIntermediate +from openapi_client.models.post_sheepbeef200_response_intermediate_beef import PostSheepbeef200ResponseIntermediateBeef +from openapi_client.models.post_sheepbeef200_response_intermediate_sheep import PostSheepbeef200ResponseIntermediateSheep +from openapi_client.models.post_sheepbeef200_response_net import PostSheepbeef200ResponseNet +from openapi_client.models.post_sheepbeef_request import PostSheepbeefRequest +from openapi_client.models.post_sheepbeef_request_vegetation_inner import PostSheepbeefRequestVegetationInner +from openapi_client.models.post_sugar200_response import PostSugar200Response +from openapi_client.models.post_sugar200_response_intermediate_inner import PostSugar200ResponseIntermediateInner +from openapi_client.models.post_sugar200_response_intermediate_inner_intensities import PostSugar200ResponseIntermediateInnerIntensities +from openapi_client.models.post_sugar_request import PostSugarRequest +from openapi_client.models.post_sugar_request_crops_inner import PostSugarRequestCropsInner +from openapi_client.models.post_vineyard200_response import PostVineyard200Response +from openapi_client.models.post_vineyard200_response_intermediate_inner import PostVineyard200ResponseIntermediateInner +from openapi_client.models.post_vineyard200_response_intermediate_inner_intensities import PostVineyard200ResponseIntermediateInnerIntensities +from openapi_client.models.post_vineyard200_response_net import PostVineyard200ResponseNet +from openapi_client.models.post_vineyard200_response_scope1 import PostVineyard200ResponseScope1 +from openapi_client.models.post_vineyard200_response_scope3 import PostVineyard200ResponseScope3 +from openapi_client.models.post_vineyard_request import PostVineyardRequest +from openapi_client.models.post_vineyard_request_vegetation_inner import PostVineyardRequestVegetationInner +from openapi_client.models.post_vineyard_request_vineyards_inner import PostVineyardRequestVineyardsInner +from openapi_client.models.post_wildcatchfishery200_response import PostWildcatchfishery200Response +from openapi_client.models.post_wildcatchfishery200_response_intensities import PostWildcatchfishery200ResponseIntensities +from openapi_client.models.post_wildcatchfishery200_response_intermediate_inner import PostWildcatchfishery200ResponseIntermediateInner +from openapi_client.models.post_wildcatchfishery200_response_scope1 import PostWildcatchfishery200ResponseScope1 +from openapi_client.models.post_wildcatchfishery_request import PostWildcatchfisheryRequest +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner import PostWildcatchfisheryRequestEnterprisesInner +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner_bait_inner import PostWildcatchfisheryRequestEnterprisesInnerBaitInner +from openapi_client.models.post_wildseafisheries200_response import PostWildseafisheries200Response +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner import PostWildseafisheries200ResponseIntermediateInner +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner_intensities import PostWildseafisheries200ResponseIntermediateInnerIntensities +from openapi_client.models.post_wildseafisheries200_response_scope1 import PostWildseafisheries200ResponseScope1 +from openapi_client.models.post_wildseafisheries200_response_scope3 import PostWildseafisheries200ResponseScope3 +from openapi_client.models.post_wildseafisheries_request import PostWildseafisheriesRequest +from openapi_client.models.post_wildseafisheries_request_enterprises_inner import PostWildseafisheriesRequestEnterprisesInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_bait_inner import PostWildseafisheriesRequestEnterprisesInnerBaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_custombait_inner import PostWildseafisheriesRequestEnterprisesInnerCustombaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_flights_inner import PostWildseafisheriesRequestEnterprisesInnerFlightsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_refrigerants_inner import PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_transports_inner import PostWildseafisheriesRequestEnterprisesInnerTransportsInner diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response.py new file mode 100644 index 00000000..fa915273 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response.py @@ -0,0 +1,151 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_intensities import PostAquaculture200ResponseIntensities +from openapi_client.models.post_aquaculture200_response_intermediate_inner import PostAquaculture200ResponseIntermediateInner +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope1 import PostAquaculture200ResponseScope1 +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200Response(BaseModel): + """ + Emissions calculation output for the `aquaculture` calculator + """ # noqa: E501 + scope1: PostAquaculture200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostAquaculture200ResponseScope3 + purchased_offsets: PostAquaculture200ResponsePurchasedOffsets = Field(alias="purchasedOffsets") + net: PostAquaculture200ResponseNet + intensities: PostAquaculture200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostAquaculture200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "purchasedOffsets", "net", "intensities", "carbonSequestration", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchased_offsets + if self.purchased_offsets: + _dict['purchasedOffsets'] = self.purchased_offsets.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostAquaculture200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostAquaculture200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "purchasedOffsets": PostAquaculture200ResponsePurchasedOffsets.from_dict(obj["purchasedOffsets"]) if obj.get("purchasedOffsets") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostAquaculture200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostAquaculture200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_carbon_sequestration.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_carbon_sequestration.py new file mode 100644 index 00000000..7d3cb9c5 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_carbon_sequestration.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseCarbonSequestration(BaseModel): + """ + Carbon sequestration, in tonnes-CO2e + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Annual amount of carbon sequestered, in tonnes-CO2e") + intermediate: List[Union[StrictFloat, StrictInt]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseCarbonSequestration from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseCarbonSequestration from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "intermediate": obj.get("intermediate") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intensities.py new file mode 100644 index 00000000..77d5ab29 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseIntensities(BaseModel): + """ + PostAquaculture200ResponseIntensities + """ # noqa: E501 + total_harvest_weight_kg: Union[StrictFloat, StrictInt] = Field(description="Total harvest weight in kg", alias="totalHarvestWeightKg") + aquaculture_excluding_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Aquaculture emissions intensity excluding sequestration, in kg-CO2e/kg", alias="aquacultureExcludingCarbonOffsets") + aquaculture_including_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Aquaculture emissions intensity including sequestration, in kg-CO2e/kg", alias="aquacultureIncludingCarbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["totalHarvestWeightKg", "aquacultureExcludingCarbonOffsets", "aquacultureIncludingCarbonOffsets"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "totalHarvestWeightKg": obj.get("totalHarvestWeightKg"), + "aquacultureExcludingCarbonOffsets": obj.get("aquacultureExcludingCarbonOffsets"), + "aquacultureIncludingCarbonOffsets": obj.get("aquacultureIncludingCarbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner.py new file mode 100644 index 00000000..1ded2b39 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intensities import PostAquaculture200ResponseIntensities +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope1 import PostAquaculture200ResponseScope1 +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Aquaculture calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostAquaculture200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostAquaculture200ResponseScope3 + intensities: PostAquaculture200ResponseIntensities + net: PostAquaculture200ResponseNet + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "intensities", "net", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostAquaculture200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostAquaculture200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "intensities": PostAquaculture200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner_carbon_sequestration.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner_carbon_sequestration.py new file mode 100644 index 00000000..b27c0e02 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_intermediate_inner_carbon_sequestration.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseIntermediateInnerCarbonSequestration(BaseModel): + """ + Carbon sequestration, in tonnes-CO2e + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Annual amount of carbon sequestered, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntermediateInnerCarbonSequestration from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseIntermediateInnerCarbonSequestration from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_net.py new file mode 100644 index 00000000..49cce329 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseNet(BaseModel): + """ + Net emissions for the activity + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_purchased_offsets.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_purchased_offsets.py new file mode 100644 index 00000000..a11629d0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_purchased_offsets.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponsePurchasedOffsets(BaseModel): + """ + Purchased offsets, in tonnes-CO2e + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Annual amount of carbon sequestered, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponsePurchasedOffsets from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponsePurchasedOffsets from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope1.py new file mode 100644 index 00000000..041291b1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope1.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + hfcs_refrigerant_leakage: Union[StrictFloat, StrictInt] = Field(description="Emissions from refrigerant leakage, in tonnes-HFCs", alias="hfcsRefrigerantLeakage") + waste_water_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from wastewater, in tonnes-CO2e", alias="wasteWaterCO2") + composted_solid_waste_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from composted solid waste, in tonnes-CO2e", alias="compostedSolidWasteCO2") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total_hfcs: Union[StrictFloat, StrictInt] = Field(description="Total HFCs scope 1 emissions, in tonnes-CO2e", alias="totalHFCs") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "hfcsRefrigerantLeakage", "wasteWaterCO2", "compostedSolidWasteCO2", "totalCO2", "totalCH4", "totalN2O", "totalHFCs", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "hfcsRefrigerantLeakage": obj.get("hfcsRefrigerantLeakage"), + "wasteWaterCO2": obj.get("wasteWaterCO2"), + "compostedSolidWasteCO2": obj.get("compostedSolidWasteCO2"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "totalHFCs": obj.get("totalHFCs"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope2.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope2.py new file mode 100644 index 00000000..d127ec17 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope2.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseScope2(BaseModel): + """ + Scope 2 greenhouse gas emissions are the emissions released to the atmosphere from the indirect consumption of an energy commodity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 2 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["electricity", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "electricity": obj.get("electricity"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope3.py new file mode 100644 index 00000000..9c903954 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture200_response_scope3.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquaculture200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + purchased_bait: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased bait, in tonnes-CO2e", alias="purchasedBait") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + commercial_flights: Union[StrictFloat, StrictInt] = Field(description="Emissions from commercial flights, in tonnes-CO2e", alias="commercialFlights") + inbound_freight: Union[StrictFloat, StrictInt] = Field(description="Emissions from inbound freight, in tonnes-CO2e", alias="inboundFreight") + outbound_freight: Union[StrictFloat, StrictInt] = Field(description="Emissions from outbound freight, in tonnes-CO2e", alias="outboundFreight") + solid_waste_sent_offsite: Union[StrictFloat, StrictInt] = Field(description="Emissions from solid waste sent offsite, in tonnes-CO2e", alias="solidWasteSentOffsite") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["purchasedBait", "electricity", "fuel", "commercialFlights", "inboundFreight", "outboundFreight", "solidWasteSentOffsite", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquaculture200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "purchasedBait": obj.get("purchasedBait"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "commercialFlights": obj.get("commercialFlights"), + "inboundFreight": obj.get("inboundFreight"), + "outboundFreight": obj.get("outboundFreight"), + "solidWasteSentOffsite": obj.get("solidWasteSentOffsite"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request.py new file mode 100644 index 00000000..0c42ea5e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture_request_enterprises_inner import PostAquacultureRequestEnterprisesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequest(BaseModel): + """ + Input data required for the `aquaculture` calculator + """ # noqa: E501 + enterprises: List[PostAquacultureRequestEnterprisesInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["enterprises"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in enterprises (list) + _items = [] + if self.enterprises: + for _item_enterprises in self.enterprises: + if _item_enterprises: + _items.append(_item_enterprises.to_dict()) + _dict['enterprises'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "enterprises": [PostAquacultureRequestEnterprisesInner.from_dict(_item) for _item in obj["enterprises"]] if obj.get("enterprises") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner.py new file mode 100644 index 00000000..a3905b31 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner.py @@ -0,0 +1,210 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_aquaculture_request_enterprises_inner_bait_inner import PostAquacultureRequestEnterprisesInnerBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_custom_bait_inner import PostAquacultureRequestEnterprisesInnerCustomBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_inbound_freight_inner import PostAquacultureRequestEnterprisesInnerInboundFreightInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_refrigerants_inner import PostAquacultureRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInner(BaseModel): + """ + Input data required for a single aquaculture enterprise + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + production_system: StrictStr = Field(description="Production system of the aquaculture enterprise", alias="productionSystem") + total_harvest_kg: Union[StrictFloat, StrictInt] = Field(description="Total harvest in kg", alias="totalHarvestKg") + refrigerants: List[PostAquacultureRequestEnterprisesInnerRefrigerantsInner] = Field(description="Refrigerant type") + bait: List[PostAquacultureRequestEnterprisesInnerBaitInner] = Field(description="Bait purchases") + custom_bait: List[PostAquacultureRequestEnterprisesInnerCustomBaitInner] = Field(description="Custom bait purchases", alias="customBait") + inbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods to the enterprise", alias="inboundFreight") + outbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods from the enterprise", alias="outboundFreight") + total_commercial_flights_km: Union[StrictFloat, StrictInt] = Field(description="Total distance of commercial flights, in km (kilometers)", alias="totalCommercialFlightsKm") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + fuel: PostAquacultureRequestEnterprisesInnerFuel + fluid_waste: List[PostAquacultureRequestEnterprisesInnerFluidWasteInner] = Field(description="Amount of fluid waste, in kL (kilolitres)", alias="fluidWaste") + solid_waste: PostAquacultureRequestEnterprisesInnerSolidWaste = Field(alias="solidWaste") + carbon_offsets: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0)", alias="carbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "productionSystem", "totalHarvestKg", "refrigerants", "bait", "customBait", "inboundFreight", "outboundFreight", "totalCommercialFlightsKm", "electricityRenewable", "electricityUse", "electricitySource", "fuel", "fluidWaste", "solidWaste", "carbonOffsets"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('production_system') + def production_system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Abalone Farming', 'Mussel Farming', 'Offshore Caged Aquaculture', 'Onland Fish Farming', 'Onshore Hatchery', 'Other', 'Oyster Farming', 'Pearl Farming', 'Prawn Farming', 'Seaweed and Macroalgae Farming']): + raise ValueError("must be one of enum values ('Abalone Farming', 'Mussel Farming', 'Offshore Caged Aquaculture', 'Onland Fish Farming', 'Onshore Hatchery', 'Other', 'Oyster Farming', 'Pearl Farming', 'Prawn Farming', 'Seaweed and Macroalgae Farming')") + return value + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in refrigerants (list) + _items = [] + if self.refrigerants: + for _item_refrigerants in self.refrigerants: + if _item_refrigerants: + _items.append(_item_refrigerants.to_dict()) + _dict['refrigerants'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bait (list) + _items = [] + if self.bait: + for _item_bait in self.bait: + if _item_bait: + _items.append(_item_bait.to_dict()) + _dict['bait'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in custom_bait (list) + _items = [] + if self.custom_bait: + for _item_custom_bait in self.custom_bait: + if _item_custom_bait: + _items.append(_item_custom_bait.to_dict()) + _dict['customBait'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in inbound_freight (list) + _items = [] + if self.inbound_freight: + for _item_inbound_freight in self.inbound_freight: + if _item_inbound_freight: + _items.append(_item_inbound_freight.to_dict()) + _dict['inboundFreight'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in outbound_freight (list) + _items = [] + if self.outbound_freight: + for _item_outbound_freight in self.outbound_freight: + if _item_outbound_freight: + _items.append(_item_outbound_freight.to_dict()) + _dict['outboundFreight'] = _items + # override the default output from pydantic by calling `to_dict()` of fuel + if self.fuel: + _dict['fuel'] = self.fuel.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in fluid_waste (list) + _items = [] + if self.fluid_waste: + for _item_fluid_waste in self.fluid_waste: + if _item_fluid_waste: + _items.append(_item_fluid_waste.to_dict()) + _dict['fluidWaste'] = _items + # override the default output from pydantic by calling `to_dict()` of solid_waste + if self.solid_waste: + _dict['solidWaste'] = self.solid_waste.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "productionSystem": obj.get("productionSystem"), + "totalHarvestKg": obj.get("totalHarvestKg"), + "refrigerants": [PostAquacultureRequestEnterprisesInnerRefrigerantsInner.from_dict(_item) for _item in obj["refrigerants"]] if obj.get("refrigerants") is not None else None, + "bait": [PostAquacultureRequestEnterprisesInnerBaitInner.from_dict(_item) for _item in obj["bait"]] if obj.get("bait") is not None else None, + "customBait": [PostAquacultureRequestEnterprisesInnerCustomBaitInner.from_dict(_item) for _item in obj["customBait"]] if obj.get("customBait") is not None else None, + "inboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["inboundFreight"]] if obj.get("inboundFreight") is not None else None, + "outboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["outboundFreight"]] if obj.get("outboundFreight") is not None else None, + "totalCommercialFlightsKm": obj.get("totalCommercialFlightsKm"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "electricitySource": obj.get("electricitySource"), + "fuel": PostAquacultureRequestEnterprisesInnerFuel.from_dict(obj["fuel"]) if obj.get("fuel") is not None else None, + "fluidWaste": [PostAquacultureRequestEnterprisesInnerFluidWasteInner.from_dict(_item) for _item in obj["fluidWaste"]] if obj.get("fluidWaste") is not None else None, + "solidWaste": PostAquacultureRequestEnterprisesInnerSolidWaste.from_dict(obj["solidWaste"]) if obj.get("solidWaste") is not None else None, + "carbonOffsets": obj.get("carbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_bait_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_bait_inner.py new file mode 100644 index 00000000..c5b5aed0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_bait_inner.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerBaitInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerBaitInner + """ # noqa: E501 + type: StrictStr = Field(description="Bait product type") + purchased_tonnes: Union[StrictFloat, StrictInt] = Field(description="Purchased product in tonnes", alias="purchasedTonnes") + additional_ingredients: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Additional ingredient fraction, from 0 to 1", alias="additionalIngredients") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of additional ingredients, in kg CO2e/kg bait (default 0)", alias="emissionsIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "purchasedTonnes", "additionalIngredients", "emissionsIntensity"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Whole Sardines', 'Low Animal Protein Formulated Feed', 'High Animal Protein Formulated Feed', 'Cereal Grain', 'Squid', 'Whole Fish']): + raise ValueError("must be one of enum values ('Whole Sardines', 'Low Animal Protein Formulated Feed', 'High Animal Protein Formulated Feed', 'Cereal Grain', 'Squid', 'Whole Fish')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerBaitInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerBaitInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "purchasedTonnes": obj.get("purchasedTonnes"), + "additionalIngredients": obj.get("additionalIngredients"), + "emissionsIntensity": obj.get("emissionsIntensity") if obj.get("emissionsIntensity") is not None else 0 + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_custom_bait_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_custom_bait_inner.py new file mode 100644 index 00000000..a60ec025 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_custom_bait_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerCustomBaitInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerCustomBaitInner + """ # noqa: E501 + purchased_tonnes: Union[StrictFloat, StrictInt] = Field(description="Purchased product in tonnes", alias="purchasedTonnes") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of product, in kg CO2e/kg bait", alias="emissionsIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["purchasedTonnes", "emissionsIntensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerCustomBaitInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerCustomBaitInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "purchasedTonnes": obj.get("purchasedTonnes"), + "emissionsIntensity": obj.get("emissionsIntensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fluid_waste_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fluid_waste_inner.py new file mode 100644 index 00000000..d6465128 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fluid_waste_inner.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerFluidWasteInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerFluidWasteInner + """ # noqa: E501 + fluid_waste_kl: Union[StrictFloat, StrictInt] = Field(description="Amount of fluid waste, in kL (kilolitres)", alias="fluidWasteKl") + fluid_waste_treatment_type: StrictStr = Field(description="Type of fluid waste treatment", alias="fluidWasteTreatmentType") + average_inlet_cod: Union[StrictFloat, StrictInt] = Field(description="Average inlet COD (mg per litre)", alias="averageInletCOD") + average_outlet_cod: Union[StrictFloat, StrictInt] = Field(description="Average outlet COD (mg per litre)", alias="averageOutletCOD") + flared_combusted_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of waste flared or combusted, between 0 and 1", alias="flaredCombustedFraction") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fluidWasteKl", "fluidWasteTreatmentType", "averageInletCOD", "averageOutletCOD", "flaredCombustedFraction"] + + @field_validator('fluid_waste_treatment_type') + def fluid_waste_treatment_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Managed Aerobic', 'Unmanaged Aerobic', 'Anaerobic Digester/Reactor', 'Shallow Anaerobic Lagoon <2m', 'Deep Anaerobic Lagoon >2m']): + raise ValueError("must be one of enum values ('Managed Aerobic', 'Unmanaged Aerobic', 'Anaerobic Digester/Reactor', 'Shallow Anaerobic Lagoon <2m', 'Deep Anaerobic Lagoon >2m')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFluidWasteInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFluidWasteInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fluidWasteKl": obj.get("fluidWasteKl"), + "fluidWasteTreatmentType": obj.get("fluidWasteTreatmentType"), + "averageInletCOD": obj.get("averageInletCOD"), + "averageOutletCOD": obj.get("averageOutletCOD"), + "flaredCombustedFraction": obj.get("flaredCombustedFraction") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel.py new file mode 100644 index 00000000..ef650e9c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner import PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerFuel(BaseModel): + """ + Fuels used in this enterprise + """ # noqa: E501 + transport_fuel: List[PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner] = Field(description="A list of fuels used in transportation and vehicles", alias="transportFuel") + stationary_fuel: List[PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner] = Field(description="A list of fuels used in stationary applications", alias="stationaryFuel") + natural_gas: Union[StrictFloat, StrictInt] = Field(description="Amount of natural gas consumed in Mj (megajoules)", alias="naturalGas") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["transportFuel", "stationaryFuel", "naturalGas"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in transport_fuel (list) + _items = [] + if self.transport_fuel: + for _item_transport_fuel in self.transport_fuel: + if _item_transport_fuel: + _items.append(_item_transport_fuel.to_dict()) + _dict['transportFuel'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in stationary_fuel (list) + _items = [] + if self.stationary_fuel: + for _item_stationary_fuel in self.stationary_fuel: + if _item_stationary_fuel: + _items.append(_item_stationary_fuel.to_dict()) + _dict['stationaryFuel'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "transportFuel": [PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner.from_dict(_item) for _item in obj["transportFuel"]] if obj.get("transportFuel") is not None else None, + "stationaryFuel": [PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner.from_dict(_item) for _item in obj["stationaryFuel"]] if obj.get("stationaryFuel") is not None else None, + "naturalGas": obj.get("naturalGas") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner.py new file mode 100644 index 00000000..6a339e13 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_stationary_fuel_inner.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner + """ # noqa: E501 + type: StrictStr = Field(description="Type of fuel") + amount_litres: Union[StrictFloat, StrictInt] = Field(description="Amount of fuel consumed (litres)", alias="amountLitres") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "amountLitres"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['petrol', 'diesel', 'lpg', 'ethanol', 'biodiesel', 'renewable diesel', 'other biofuels', 'lng']): + raise ValueError("must be one of enum values ('petrol', 'diesel', 'lpg', 'ethanol', 'biodiesel', 'renewable diesel', 'other biofuels', 'lng')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuelStationaryFuelInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "amountLitres": obj.get("amountLitres") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner.py new file mode 100644 index 00000000..49dc1cec --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_fuel_transport_fuel_inner.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner + """ # noqa: E501 + type: StrictStr = Field(description="Type of fuel") + amount_litres: Union[StrictFloat, StrictInt] = Field(description="Amount of fuel consumed (litres)", alias="amountLitres") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "amountLitres"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['petrol', 'diesel', 'lpg', 'ethanol', 'biodiesel', 'renewable diesel', 'other biofuels', 'lng', 'fuel oil', 'avgas', 'jet a-1', 'jet b']): + raise ValueError("must be one of enum values ('petrol', 'diesel', 'lpg', 'ethanol', 'biodiesel', 'renewable diesel', 'other biofuels', 'lng', 'fuel oil', 'avgas', 'jet a-1', 'jet b')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerFuelTransportFuelInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "amountLitres": obj.get("amountLitres") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_inbound_freight_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_inbound_freight_inner.py new file mode 100644 index 00000000..bd4125c8 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_inbound_freight_inner.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerInboundFreightInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerInboundFreightInner + """ # noqa: E501 + type: StrictStr = Field(description="Type of freight used") + total_km_tonnes: Union[StrictFloat, StrictInt] = Field(description="Total distance of freight, in kilometre tonnes", alias="totalKmTonnes") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "totalKmTonnes"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Truck', 'Rail', 'Long haul flight', 'Medium haul flight', 'Small container ship', 'Large container ship']): + raise ValueError("must be one of enum values ('Truck', 'Rail', 'Long haul flight', 'Medium haul flight', 'Small container ship', 'Large container ship')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerInboundFreightInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerInboundFreightInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "totalKmTonnes": obj.get("totalKmTonnes") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_refrigerants_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_refrigerants_inner.py new file mode 100644 index 00000000..a27e25b2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_refrigerants_inner.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerRefrigerantsInner(BaseModel): + """ + PostAquacultureRequestEnterprisesInnerRefrigerantsInner + """ # noqa: E501 + refrigerant: StrictStr = Field(description="Refrigerant type") + charge_size: Union[StrictFloat, StrictInt] = Field(description="Amount of refrigerant contained in the appliance, in kg", alias="chargeSize") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["refrigerant", "chargeSize"] + + @field_validator('refrigerant') + def refrigerant_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A']): + raise ValueError("must be one of enum values ('HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerRefrigerantsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerRefrigerantsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "refrigerant": obj.get("refrigerant"), + "chargeSize": obj.get("chargeSize") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_solid_waste.py b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_solid_waste.py new file mode 100644 index 00000000..bb121c1c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_aquaculture_request_enterprises_inner_solid_waste.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostAquacultureRequestEnterprisesInnerSolidWaste(BaseModel): + """ + Solid waste management + """ # noqa: E501 + sent_offsite_tonnes: Union[StrictFloat, StrictInt] = Field(description="Amount of solid waste sent offsite to landfill, in tonnes", alias="sentOffsiteTonnes") + onsite_composting_tonnes: Union[StrictFloat, StrictInt] = Field(description="Amount of solid waste composted on site, in tonnes", alias="onsiteCompostingTonnes") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["sentOffsiteTonnes", "onsiteCompostingTonnes"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerSolidWaste from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostAquacultureRequestEnterprisesInnerSolidWaste from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "sentOffsiteTonnes": obj.get("sentOffsiteTonnes"), + "onsiteCompostingTonnes": obj.get("onsiteCompostingTonnes") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response.py new file mode 100644 index 00000000..a58a1720 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_intermediate_inner import PostBeef200ResponseIntermediateInner +from openapi_client.models.post_beef200_response_intermediate_inner_intensities import PostBeef200ResponseIntermediateInnerIntensities +from openapi_client.models.post_beef200_response_net import PostBeef200ResponseNet +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200Response(BaseModel): + """ + Emissions calculation output for the `beef` calculator + """ # noqa: E501 + scope1: PostBeef200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostBeef200ResponseIntermediateInner] + net: PostBeef200ResponseNet + intensities: PostBeef200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBeef200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostBeef200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostBeef200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostBeef200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner.py new file mode 100644 index 00000000..3a90619f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_intermediate_inner_intensities import PostBeef200ResponseIntermediateInnerIntensities +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Beef calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostBeef200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostBeef200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostBeef200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostBeef200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..f84c2c55 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_intermediate_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostBeef200ResponseIntermediateInnerIntensities + """ # noqa: E501 + liveweight_beef_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Amount of beef produced in kg liveweight", alias="liveweightBeefProducedKg") + beef_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef excluding sequestration, in kg-CO2e/kg liveweight", alias="beefExcludingSequestration") + beef_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef including sequestration, in kg-CO2e/kg liveweight", alias="beefIncludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["liveweightBeefProducedKg", "beefExcludingSequestration", "beefIncludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "liveweightBeefProducedKg": obj.get("liveweightBeefProducedKg"), + "beefExcludingSequestration": obj.get("beefExcludingSequestration"), + "beefIncludingSequestration": obj.get("beefIncludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_net.py new file mode 100644 index 00000000..d6321860 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_net.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200ResponseNet(BaseModel): + """ + PostBeef200ResponseNet + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Total net emissions of this activity, in tonnes-CO2e/year") + beef: Union[StrictFloat, StrictInt] = Field(description="Net emissions of beef, in tonnes-CO2e/year") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "beef"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "beef": obj.get("beef") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope1.py new file mode 100644 index 00000000..36335ae3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope1.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + enteric_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from enteric fermentation, in tonnes-CO2e", alias="entericCH4") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + urine_and_dung_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from urine and dung, in tonnes-CO2e", alias="urineAndDungN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + savannah_burning_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from field burning, in tonnes-CO2e", alias="savannahBurningN2O") + savannah_burning_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from field burning, in tonnes-CO2e", alias="savannahBurningCH4") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "fertiliserN2O", "entericCH4", "manureManagementCH4", "urineAndDungN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "savannahBurningN2O", "savannahBurningCH4", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "entericCH4": obj.get("entericCH4"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "urineAndDungN2O": obj.get("urineAndDungN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "savannahBurningN2O": obj.get("savannahBurningN2O"), + "savannahBurningCH4": obj.get("savannahBurningCH4"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope3.py new file mode 100644 index 00000000..0587173d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef200_response_scope3.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeef200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + purchased_mineral_supplementation: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased mineral supplementation, in tonnes-CO2e", alias="purchasedMineralSupplementation") + purchased_feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased feed, in tonnes-CO2e", alias="purchasedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + purchased_livestock: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased livestock, in tonnes-CO2e", alias="purchasedLivestock") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "purchasedMineralSupplementation", "purchasedFeed", "herbicide", "electricity", "fuel", "lime", "purchasedLivestock", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeef200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeef200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "purchasedMineralSupplementation": obj.get("purchasedMineralSupplementation"), + "purchasedFeed": obj.get("purchasedFeed"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "purchasedLivestock": obj.get("purchasedLivestock"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request.py new file mode 100644 index 00000000..be1a93e3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request.py @@ -0,0 +1,142 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_beef_request_beef_inner import PostBeefRequestBeefInner +from openapi_client.models.post_beef_request_burning_inner import PostBeefRequestBurningInner +from openapi_client.models.post_beef_request_vegetation_inner import PostBeefRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequest(BaseModel): + """ + Input data required for the `beef` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + north_of_tropic_of_capricorn: StrictBool = Field(description="Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude", alias="northOfTropicOfCapricorn") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + beef: List[PostBeefRequestBeefInner] + burning: List[PostBeefRequestBurningInner] + vegetation: List[PostBeefRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "northOfTropicOfCapricorn", "rainfallAbove600", "beef", "burning", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in beef (list) + _items = [] + if self.beef: + for _item_beef in self.beef: + if _item_beef: + _items.append(_item_beef.to_dict()) + _dict['beef'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in burning (list) + _items = [] + if self.burning: + for _item_burning in self.burning: + if _item_burning: + _items.append(_item_burning.to_dict()) + _dict['burning'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "northOfTropicOfCapricorn": obj.get("northOfTropicOfCapricorn"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "beef": [PostBeefRequestBeefInner.from_dict(_item) for _item in obj["beef"]] if obj.get("beef") is not None else None, + "burning": [PostBeefRequestBurningInner.from_dict(_item) for _item in obj["burning"]] if obj.get("burning") is not None else None, + "vegetation": [PostBeefRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner.py new file mode 100644 index 00000000..72b66f7d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner.py @@ -0,0 +1,159 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_classes import PostBeefRequestBeefInnerClasses +from openapi_client.models.post_beef_request_beef_inner_cows_calving import PostBeefRequestBeefInnerCowsCalving +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_beef_request_beef_inner_mineral_supplementation import PostBeefRequestBeefInnerMineralSupplementation +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInner(BaseModel): + """ + PostBeefRequestBeefInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostBeefRequestBeefInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + mineral_supplementation: PostBeefRequestBeefInnerMineralSupplementation = Field(alias="mineralSupplementation") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + cottonseed_feed: Union[StrictFloat, StrictInt] = Field(description="Cotton seed purchased for cattle feed in tonnes", alias="cottonseedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + cows_calving: PostBeefRequestBeefInnerCowsCalving = Field(alias="cowsCalving") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "mineralSupplementation", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "cottonseedFeed", "herbicide", "herbicideOther", "cowsCalving"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of mineral_supplementation + if self.mineral_supplementation: + _dict['mineralSupplementation'] = self.mineral_supplementation.to_dict() + # override the default output from pydantic by calling `to_dict()` of cows_calving + if self.cows_calving: + _dict['cowsCalving'] = self.cows_calving.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostBeefRequestBeefInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "mineralSupplementation": PostBeefRequestBeefInnerMineralSupplementation.from_dict(obj["mineralSupplementation"]) if obj.get("mineralSupplementation") is not None else None, + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "cottonseedFeed": obj.get("cottonseedFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "cowsCalving": PostBeefRequestBeefInnerCowsCalving.from_dict(obj["cowsCalving"]) if obj.get("cowsCalving") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes.py new file mode 100644 index 00000000..bb82d56a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes.py @@ -0,0 +1,195 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1 import PostBeefRequestBeefInnerClassesBullsGt1 +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_traded import PostBeefRequestBeefInnerClassesBullsGt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2 import PostBeefRequestBeefInnerClassesCowsGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_cows_gt2_traded import PostBeefRequestBeefInnerClassesCowsGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2 import PostBeefRequestBeefInnerClassesHeifers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers1_to2_traded import PostBeefRequestBeefInnerClassesHeifers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2 import PostBeefRequestBeefInnerClassesHeifersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_gt2_traded import PostBeefRequestBeefInnerClassesHeifersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1 import PostBeefRequestBeefInnerClassesHeifersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_heifers_lt1_traded import PostBeefRequestBeefInnerClassesHeifersLt1Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2 import PostBeefRequestBeefInnerClassesSteers1To2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers1_to2_traded import PostBeefRequestBeefInnerClassesSteers1To2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2 import PostBeefRequestBeefInnerClassesSteersGt2 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_gt2_traded import PostBeefRequestBeefInnerClassesSteersGt2Traded +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1 import PostBeefRequestBeefInnerClassesSteersLt1 +from openapi_client.models.post_beef_request_beef_inner_classes_steers_lt1_traded import PostBeefRequestBeefInnerClassesSteersLt1Traded +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClasses(BaseModel): + """ + Beef classes of different types and age ranges + """ # noqa: E501 + bulls_gt1: Optional[PostBeefRequestBeefInnerClassesBullsGt1] = Field(default=None, alias="bullsGt1") + bulls_gt1_traded: Optional[PostBeefRequestBeefInnerClassesBullsGt1Traded] = Field(default=None, alias="bullsGt1Traded") + steers_lt1: Optional[PostBeefRequestBeefInnerClassesSteersLt1] = Field(default=None, alias="steersLt1") + steers_lt1_traded: Optional[PostBeefRequestBeefInnerClassesSteersLt1Traded] = Field(default=None, alias="steersLt1Traded") + steers1_to2: Optional[PostBeefRequestBeefInnerClassesSteers1To2] = Field(default=None, alias="steers1To2") + steers1_to2_traded: Optional[PostBeefRequestBeefInnerClassesSteers1To2Traded] = Field(default=None, alias="steers1To2Traded") + steers_gt2: Optional[PostBeefRequestBeefInnerClassesSteersGt2] = Field(default=None, alias="steersGt2") + steers_gt2_traded: Optional[PostBeefRequestBeefInnerClassesSteersGt2Traded] = Field(default=None, alias="steersGt2Traded") + cows_gt2: Optional[PostBeefRequestBeefInnerClassesCowsGt2] = Field(default=None, alias="cowsGt2") + cows_gt2_traded: Optional[PostBeefRequestBeefInnerClassesCowsGt2Traded] = Field(default=None, alias="cowsGt2Traded") + heifers_lt1: Optional[PostBeefRequestBeefInnerClassesHeifersLt1] = Field(default=None, alias="heifersLt1") + heifers_lt1_traded: Optional[PostBeefRequestBeefInnerClassesHeifersLt1Traded] = Field(default=None, alias="heifersLt1Traded") + heifers1_to2: Optional[PostBeefRequestBeefInnerClassesHeifers1To2] = Field(default=None, alias="heifers1To2") + heifers1_to2_traded: Optional[PostBeefRequestBeefInnerClassesHeifers1To2Traded] = Field(default=None, alias="heifers1To2Traded") + heifers_gt2: Optional[PostBeefRequestBeefInnerClassesHeifersGt2] = Field(default=None, alias="heifersGt2") + heifers_gt2_traded: Optional[PostBeefRequestBeefInnerClassesHeifersGt2Traded] = Field(default=None, alias="heifersGt2Traded") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bullsGt1", "bullsGt1Traded", "steersLt1", "steersLt1Traded", "steers1To2", "steers1To2Traded", "steersGt2", "steersGt2Traded", "cowsGt2", "cowsGt2Traded", "heifersLt1", "heifersLt1Traded", "heifers1To2", "heifers1To2Traded", "heifersGt2", "heifersGt2Traded"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of bulls_gt1 + if self.bulls_gt1: + _dict['bullsGt1'] = self.bulls_gt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of bulls_gt1_traded + if self.bulls_gt1_traded: + _dict['bullsGt1Traded'] = self.bulls_gt1_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers_lt1 + if self.steers_lt1: + _dict['steersLt1'] = self.steers_lt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers_lt1_traded + if self.steers_lt1_traded: + _dict['steersLt1Traded'] = self.steers_lt1_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers1_to2 + if self.steers1_to2: + _dict['steers1To2'] = self.steers1_to2.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers1_to2_traded + if self.steers1_to2_traded: + _dict['steers1To2Traded'] = self.steers1_to2_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers_gt2 + if self.steers_gt2: + _dict['steersGt2'] = self.steers_gt2.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers_gt2_traded + if self.steers_gt2_traded: + _dict['steersGt2Traded'] = self.steers_gt2_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of cows_gt2 + if self.cows_gt2: + _dict['cowsGt2'] = self.cows_gt2.to_dict() + # override the default output from pydantic by calling `to_dict()` of cows_gt2_traded + if self.cows_gt2_traded: + _dict['cowsGt2Traded'] = self.cows_gt2_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_lt1 + if self.heifers_lt1: + _dict['heifersLt1'] = self.heifers_lt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_lt1_traded + if self.heifers_lt1_traded: + _dict['heifersLt1Traded'] = self.heifers_lt1_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers1_to2 + if self.heifers1_to2: + _dict['heifers1To2'] = self.heifers1_to2.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers1_to2_traded + if self.heifers1_to2_traded: + _dict['heifers1To2Traded'] = self.heifers1_to2_traded.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_gt2 + if self.heifers_gt2: + _dict['heifersGt2'] = self.heifers_gt2.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_gt2_traded + if self.heifers_gt2_traded: + _dict['heifersGt2Traded'] = self.heifers_gt2_traded.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bullsGt1": PostBeefRequestBeefInnerClassesBullsGt1.from_dict(obj["bullsGt1"]) if obj.get("bullsGt1") is not None else None, + "bullsGt1Traded": PostBeefRequestBeefInnerClassesBullsGt1Traded.from_dict(obj["bullsGt1Traded"]) if obj.get("bullsGt1Traded") is not None else None, + "steersLt1": PostBeefRequestBeefInnerClassesSteersLt1.from_dict(obj["steersLt1"]) if obj.get("steersLt1") is not None else None, + "steersLt1Traded": PostBeefRequestBeefInnerClassesSteersLt1Traded.from_dict(obj["steersLt1Traded"]) if obj.get("steersLt1Traded") is not None else None, + "steers1To2": PostBeefRequestBeefInnerClassesSteers1To2.from_dict(obj["steers1To2"]) if obj.get("steers1To2") is not None else None, + "steers1To2Traded": PostBeefRequestBeefInnerClassesSteers1To2Traded.from_dict(obj["steers1To2Traded"]) if obj.get("steers1To2Traded") is not None else None, + "steersGt2": PostBeefRequestBeefInnerClassesSteersGt2.from_dict(obj["steersGt2"]) if obj.get("steersGt2") is not None else None, + "steersGt2Traded": PostBeefRequestBeefInnerClassesSteersGt2Traded.from_dict(obj["steersGt2Traded"]) if obj.get("steersGt2Traded") is not None else None, + "cowsGt2": PostBeefRequestBeefInnerClassesCowsGt2.from_dict(obj["cowsGt2"]) if obj.get("cowsGt2") is not None else None, + "cowsGt2Traded": PostBeefRequestBeefInnerClassesCowsGt2Traded.from_dict(obj["cowsGt2Traded"]) if obj.get("cowsGt2Traded") is not None else None, + "heifersLt1": PostBeefRequestBeefInnerClassesHeifersLt1.from_dict(obj["heifersLt1"]) if obj.get("heifersLt1") is not None else None, + "heifersLt1Traded": PostBeefRequestBeefInnerClassesHeifersLt1Traded.from_dict(obj["heifersLt1Traded"]) if obj.get("heifersLt1Traded") is not None else None, + "heifers1To2": PostBeefRequestBeefInnerClassesHeifers1To2.from_dict(obj["heifers1To2"]) if obj.get("heifers1To2") is not None else None, + "heifers1To2Traded": PostBeefRequestBeefInnerClassesHeifers1To2Traded.from_dict(obj["heifers1To2Traded"]) if obj.get("heifers1To2Traded") is not None else None, + "heifersGt2": PostBeefRequestBeefInnerClassesHeifersGt2.from_dict(obj["heifersGt2"]) if obj.get("heifersGt2") is not None else None, + "heifersGt2Traded": PostBeefRequestBeefInnerClassesHeifersGt2Traded.from_dict(obj["heifersGt2Traded"]) if obj.get("heifersGt2Traded") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1.py new file mode 100644 index 00000000..7421fe13 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesBullsGt1(BaseModel): + """ + Bulls whose age is greater than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_autumn.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_autumn.py new file mode 100644 index 00000000..4bea4d0b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_autumn.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesBullsGt1Autumn(BaseModel): + """ + PostBeefRequestBeefInnerClassesBullsGt1Autumn + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals (head)") + liveweight: Union[StrictFloat, StrictInt] = Field(description="Average liveweight of animals in kg/head (kilogram per head)") + liveweight_gain: Union[StrictFloat, StrictInt] = Field(description="Average liveweight gain in kg/day (kilogram per day)", alias="liveweightGain") + crude_protein: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Crude protein percent, between 0 and 100", alias="crudeProtein") + dry_matter_digestibility: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Dry matter digestibility percent, between 0 and 100", alias="dryMatterDigestibility") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "liveweight", "liveweightGain", "crudeProtein", "dryMatterDigestibility"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1Autumn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1Autumn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "liveweight": obj.get("liveweight"), + "liveweightGain": obj.get("liveweightGain"), + "crudeProtein": obj.get("crudeProtein"), + "dryMatterDigestibility": obj.get("dryMatterDigestibility") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner.py new file mode 100644 index 00000000..9d352ca4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner(BaseModel): + """ + Beef purchase + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + purchase_source: StrictStr = Field(description="Source location of livestock purchase", alias="purchaseSource") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight", "purchaseSource"] + + @field_validator('purchase_source') + def purchase_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight"), + "purchaseSource": obj.get("purchaseSource") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_traded.py new file mode 100644 index 00000000..c3e24504 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_bulls_gt1_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesBullsGt1Traded(BaseModel): + """ + Traded bulls whose age is greater than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesBullsGt1Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2.py new file mode 100644 index 00000000..5f7999f9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesCowsGt2(BaseModel): + """ + Cows whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesCowsGt2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesCowsGt2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2_traded.py new file mode 100644 index 00000000..8a277b5d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_cows_gt2_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesCowsGt2Traded(BaseModel): + """ + Traded cows whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesCowsGt2Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesCowsGt2Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2.py new file mode 100644 index 00000000..c4d87b29 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifers1To2(BaseModel): + """ + Heifers whose age is between 1 and 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifers1To2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifers1To2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2_traded.py new file mode 100644 index 00000000..5e045c43 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers1_to2_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifers1To2Traded(BaseModel): + """ + Traded heifers whose age is between 1 and 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifers1To2Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifers1To2Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2.py new file mode 100644 index 00000000..7dcc2e84 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifersGt2(BaseModel): + """ + Heifers whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersGt2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersGt2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2_traded.py new file mode 100644 index 00000000..c4a67b42 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_gt2_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifersGt2Traded(BaseModel): + """ + Traded heifers whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersGt2Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersGt2Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1.py new file mode 100644 index 00000000..658cd420 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifersLt1(BaseModel): + """ + Heifers whose age is less than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersLt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersLt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1_traded.py new file mode 100644 index 00000000..7a29fdb2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_heifers_lt1_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesHeifersLt1Traded(BaseModel): + """ + Traded heifers whose age is less than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersLt1Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesHeifersLt1Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2.py new file mode 100644 index 00000000..f82bf1b7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteers1To2(BaseModel): + """ + Steers whose age is between 1 and 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteers1To2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteers1To2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2_traded.py new file mode 100644 index 00000000..f9f7ec0b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers1_to2_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteers1To2Traded(BaseModel): + """ + Traded steers whose age is between 1 and 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteers1To2Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteers1To2Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2.py new file mode 100644 index 00000000..7defab1c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteersGt2(BaseModel): + """ + Steers whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersGt2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersGt2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2_traded.py new file mode 100644 index 00000000..ec361610 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_gt2_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteersGt2Traded(BaseModel): + """ + Traded steers whose age is greater than 2 years old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersGt2Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersGt2Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1.py new file mode 100644 index 00000000..43c2f2d7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteersLt1(BaseModel): + """ + Steers whose age is less than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersLt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersLt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1_traded.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1_traded.py new file mode 100644 index 00000000..26322210 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_classes_steers_lt1_traded.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_autumn import PostBeefRequestBeefInnerClassesBullsGt1Autumn +from openapi_client.models.post_beef_request_beef_inner_classes_bulls_gt1_purchases_inner import PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerClassesSteersLt1Traded(BaseModel): + """ + Traded steers whose age is less than 1 year old + """ # noqa: E501 + autumn: PostBeefRequestBeefInnerClassesBullsGt1Autumn + winter: PostBeefRequestBeefInnerClassesBullsGt1Autumn + spring: PostBeefRequestBeefInnerClassesBullsGt1Autumn + summer: PostBeefRequestBeefInnerClassesBullsGt1Autumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Use `purchases` instead", alias="purchasedWeight") + source: Optional[StrictStr] = Field(default=None, description="Source location of livestock purchase. Deprecation note: Use `purchases` instead") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "source", "headSold", "saleWeight", "purchases"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT']): + raise ValueError("must be one of enum values ('Dairy origin', 'nth/sth/central QLD', 'nth/sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS', 'NT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersLt1Traded from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerClassesSteersLt1Traded from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBeefRequestBeefInnerClassesBullsGt1Autumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "source": obj.get("source"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBeefRequestBeefInnerClassesBullsGt1PurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_cows_calving.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_cows_calving.py new file mode 100644 index 00000000..ce27c0e5 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_cows_calving.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerCowsCalving(BaseModel): + """ + Fraction of cows calving in each season, between 0 and 1 + """ # noqa: E501 + spring: Union[StrictFloat, StrictInt] + summer: Union[StrictFloat, StrictInt] + autumn: Union[StrictFloat, StrictInt] + winter: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerCowsCalving from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerCowsCalving from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "autumn": obj.get("autumn"), + "winter": obj.get("winter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser.py new file mode 100644 index 00000000..21a246e2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_beef_inner_fertiliser_other_fertilisers_inner import PostBeefRequestBeefInnerFertiliserOtherFertilisersInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerFertiliser(BaseModel): + """ + Fertiliser used for different applications (such as dryland pasture) + """ # noqa: E501 + single_superphosphate: Union[StrictFloat, StrictInt] = Field(description="Single superphosphate usage in tonnes", alias="singleSuperphosphate") + other_type: Optional[StrictStr] = Field(default=None, description="Other N fertiliser type. Deprecation note: Use `otherFertilisers` instead", alias="otherType") + pasture_dryland: Union[StrictFloat, StrictInt] = Field(description="Urea fertiliser used for dryland pasture, in tonnes Urea", alias="pastureDryland") + pasture_irrigated: Union[StrictFloat, StrictInt] = Field(description="Urea fertiliser used for irrigated pasture, in tonnes Urea", alias="pastureIrrigated") + crops_dryland: Union[StrictFloat, StrictInt] = Field(description="Urea fertiliser used for dryland crops, in tonnes Urea", alias="cropsDryland") + crops_irrigated: Union[StrictFloat, StrictInt] = Field(description="Urea fertiliser used for irrigated crops, in tonnes Urea", alias="cropsIrrigated") + other_dryland: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Other N fertiliser used for dryland. Deprecation note: Use `otherFertilisers` instead", alias="otherDryland") + other_irrigated: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Other N fertiliser used for irrigated. Deprecation note: Use `otherFertilisers` instead", alias="otherIrrigated") + other_fertilisers: Optional[List[PostBeefRequestBeefInnerFertiliserOtherFertilisersInner]] = Field(default=None, description="Array of Other N fertiliser. Version note: If this field is set and has a length > 0, the `other` fields within this object are ignored, and this array is used instead", alias="otherFertilisers") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["singleSuperphosphate", "otherType", "pastureDryland", "pastureIrrigated", "cropsDryland", "cropsIrrigated", "otherDryland", "otherIrrigated", "otherFertilisers"] + + @field_validator('other_type') + def other_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia']): + raise ValueError("must be one of enum values ('Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerFertiliser from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in other_fertilisers (list) + _items = [] + if self.other_fertilisers: + for _item_other_fertilisers in self.other_fertilisers: + if _item_other_fertilisers: + _items.append(_item_other_fertilisers.to_dict()) + _dict['otherFertilisers'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerFertiliser from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "singleSuperphosphate": obj.get("singleSuperphosphate"), + "otherType": obj.get("otherType"), + "pastureDryland": obj.get("pastureDryland"), + "pastureIrrigated": obj.get("pastureIrrigated"), + "cropsDryland": obj.get("cropsDryland"), + "cropsIrrigated": obj.get("cropsIrrigated"), + "otherDryland": obj.get("otherDryland"), + "otherIrrigated": obj.get("otherIrrigated"), + "otherFertilisers": [PostBeefRequestBeefInnerFertiliserOtherFertilisersInner.from_dict(_item) for _item in obj["otherFertilisers"]] if obj.get("otherFertilisers") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser_other_fertilisers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser_other_fertilisers_inner.py new file mode 100644 index 00000000..953d6fea --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_fertiliser_other_fertilisers_inner.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerFertiliserOtherFertilisersInner(BaseModel): + """ + Other fertiliser, of a specific type, used for different applications (such as dryland pasture) + """ # noqa: E501 + other_type: StrictStr = Field(description="Other N fertiliser type", alias="otherType") + other_dryland: Union[StrictFloat, StrictInt] = Field(description="Other N fertiliser used for dryland. From v1.1.0, supply tonnes of product. For earlier versions, supply tonnes of N", alias="otherDryland") + other_irrigated: Union[StrictFloat, StrictInt] = Field(description="Other N fertiliser used for irrigated. From v1.1.0, supply tonnes of product. For earlier versions, supply tonnes of N", alias="otherIrrigated") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["otherType", "otherDryland", "otherIrrigated"] + + @field_validator('other_type') + def other_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia']): + raise ValueError("must be one of enum values ('Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerFertiliserOtherFertilisersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerFertiliserOtherFertilisersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "otherType": obj.get("otherType"), + "otherDryland": obj.get("otherDryland"), + "otherIrrigated": obj.get("otherIrrigated") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_mineral_supplementation.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_mineral_supplementation.py new file mode 100644 index 00000000..9d87d84e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_beef_inner_mineral_supplementation.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBeefInnerMineralSupplementation(BaseModel): + """ + Supplementation for livestock + """ # noqa: E501 + mineral_block: Union[StrictFloat, StrictInt] = Field(description="Mineral block product used, in tonnes", alias="mineralBlock") + mineral_block_urea: Union[StrictFloat, StrictInt] = Field(description="Fraction of urea content, between 0 and 1", alias="mineralBlockUrea") + weaner_block: Union[StrictFloat, StrictInt] = Field(description="Weaner block product used, in tonnes", alias="weanerBlock") + weaner_block_urea: Union[StrictFloat, StrictInt] = Field(description="Fraction of urea content, between 0 and 1", alias="weanerBlockUrea") + dry_season_mix: Union[StrictFloat, StrictInt] = Field(description="Dry season mix product used, in tonnes", alias="drySeasonMix") + dry_season_mix_urea: Union[StrictFloat, StrictInt] = Field(description="Fraction of urea content, between 0 and 1", alias="drySeasonMixUrea") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["mineralBlock", "mineralBlockUrea", "weanerBlock", "weanerBlockUrea", "drySeasonMix", "drySeasonMixUrea"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerMineralSupplementation from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBeefInnerMineralSupplementation from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "mineralBlock": obj.get("mineralBlock") if obj.get("mineralBlock") is not None else 0, + "mineralBlockUrea": obj.get("mineralBlockUrea") if obj.get("mineralBlockUrea") is not None else 0, + "weanerBlock": obj.get("weanerBlock") if obj.get("weanerBlock") is not None else 0, + "weanerBlockUrea": obj.get("weanerBlockUrea") if obj.get("weanerBlockUrea") is not None else 0, + "drySeasonMix": obj.get("drySeasonMix") if obj.get("drySeasonMix") is not None else 0, + "drySeasonMixUrea": obj.get("drySeasonMixUrea") if obj.get("drySeasonMixUrea") is not None else 0 + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner.py new file mode 100644 index 00000000..58780dd1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_burning_inner_burning import PostBeefRequestBurningInnerBurning +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBurningInner(BaseModel): + """ + Savannah burning along with allocations to beef + """ # noqa: E501 + burning: PostBeefRequestBurningInnerBurning + allocation_to_beef: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the burning that is allocated to each beef", alias="allocationToBeef") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["burning", "allocationToBeef"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBurningInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of burning + if self.burning: + _dict['burning'] = self.burning.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBurningInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "burning": PostBeefRequestBurningInnerBurning.from_dict(obj["burning"]) if obj.get("burning") is not None else None, + "allocationToBeef": obj.get("allocationToBeef") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner_burning.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner_burning.py new file mode 100644 index 00000000..ac209e92 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_burning_inner_burning.py @@ -0,0 +1,148 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestBurningInnerBurning(BaseModel): + """ + Inputs required for any savannah burning activities that took place + """ # noqa: E501 + fuel: StrictStr = Field(description="The fuel class size that was burnt") + season: StrictStr = Field(description="The time relative to the fire season in which the burning took place") + patchiness: StrictStr = Field(description="The patchiness of the savannah/vegetation that was burnt") + rainfall_zone: StrictStr = Field(description="The rainfall zone in which the burning took place", alias="rainfallZone") + years_since_last_fire: Union[StrictFloat, StrictInt] = Field(description="Time since the last fire, in years", alias="yearsSinceLastFire") + fire_scar_area: Union[StrictFloat, StrictInt] = Field(description="The total area of the fire scar, in ha (hectares)", alias="fireScarArea") + vegetation: StrictStr = Field(description="The vegetation class that was burnt") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuel", "season", "patchiness", "rainfallZone", "yearsSinceLastFire", "fireScarArea", "vegetation"] + + @field_validator('fuel') + def fuel_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['fine', 'coarse']): + raise ValueError("must be one of enum values ('fine', 'coarse')") + return value + + @field_validator('season') + def season_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['early dry season', 'late dry season']): + raise ValueError("must be one of enum values ('early dry season', 'late dry season')") + return value + + @field_validator('patchiness') + def patchiness_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['low', 'high']): + raise ValueError("must be one of enum values ('low', 'high')") + return value + + @field_validator('rainfall_zone') + def rainfall_zone_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['low', 'high']): + raise ValueError("must be one of enum values ('low', 'high')") + return value + + @field_validator('vegetation') + def vegetation_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Shrubland hummock', 'Woodland Hummock', 'Melaleuca woodland', 'Woodland Mixed', 'Open forest mixed', 'Shrubland (heath) with hummock grass', 'Woodland with hummock grass', 'Open woodland with mixed grass', 'Woodland with mixed grass', 'Woodland with tussock grass']): + raise ValueError("must be one of enum values ('Shrubland hummock', 'Woodland Hummock', 'Melaleuca woodland', 'Woodland Mixed', 'Open forest mixed', 'Shrubland (heath) with hummock grass', 'Woodland with hummock grass', 'Open woodland with mixed grass', 'Woodland with mixed grass', 'Woodland with tussock grass')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestBurningInnerBurning from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestBurningInnerBurning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuel": obj.get("fuel") if obj.get("fuel") is not None else 'coarse', + "season": obj.get("season") if obj.get("season") is not None else 'early dry season', + "patchiness": obj.get("patchiness") if obj.get("patchiness") is not None else 'high', + "rainfallZone": obj.get("rainfallZone") if obj.get("rainfallZone") is not None else 'low', + "yearsSinceLastFire": obj.get("yearsSinceLastFire") if obj.get("yearsSinceLastFire") is not None else 0, + "fireScarArea": obj.get("fireScarArea") if obj.get("fireScarArea") is not None else 0, + "vegetation": obj.get("vegetation") if obj.get("vegetation") is not None else 'Melaleuca woodland' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner.py new file mode 100644 index 00000000..fd1684f2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to beef + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + beef_proportion: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The proportion of the sequestration that is allocated to beef. Deprecation note: Please use `allocationToBeef` instead", alias="beefProportion") + allocation_to_beef: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to each beef", alias="allocationToBeef") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "beefProportion", "allocationToBeef"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "beefProportion": obj.get("beefProportion"), + "allocationToBeef": obj.get("allocationToBeef") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner_vegetation.py b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner_vegetation.py new file mode 100644 index 00000000..b4aa4f99 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_beef_request_vegetation_inner_vegetation.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBeefRequestVegetationInnerVegetation(BaseModel): + """ + Inputs required for non-productive vegetation in order to calculate carbon sequestration + """ # noqa: E501 + region: StrictStr = Field(description="The rainfall region that the vegetation is in") + tree_species: StrictStr = Field(description="The species of tree", alias="treeSpecies") + soil: StrictStr = Field(description="The soil type the tree is in") + area: Union[StrictFloat, StrictInt] = Field(description="The area of trees, in ha (hectares)") + age: Union[StrictFloat, StrictInt] = Field(description="The age of the trees, in years") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["region", "treeSpecies", "soil", "area", "age"] + + @field_validator('region') + def region_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['South West', 'Pilbara', 'Kimberley', 'Central West', 'South Coastal', 'Goldfields/Eucla', 'Gascoyne', 'Central Wheat Belt', 'Interior', 'North Coast', 'South Coast', 'Northern Tablelands', 'Southern Tablelands', 'Northern Wheat/Sheep', 'Southern Wheat/Sheep', 'Western', 'North East', 'East Coast', 'Central North/Midlands/South East', 'Central Plateau/Derwent Valley', 'West/South Coast', 'North West', 'South East', 'Murray', 'Mid-North/Flinders', 'Pastoral', 'West Coast/Eyre', 'Mallee', 'Wimmera', 'Northern Country', 'North East Vic', 'East Gippsland', 'West/South Gippsland', 'Central', 'South West Vic', 'Central Highlands/Northern', 'Central West/Flinders', 'Channel Country', 'Maranoa/Warrego', 'Darling Downs/Burnett', 'North West/Gulf', 'Darwin-Daly', 'Arnhem-Roper', 'Victoria River-TennantCreek', 'Alice Springs']): + raise ValueError("must be one of enum values ('South West', 'Pilbara', 'Kimberley', 'Central West', 'South Coastal', 'Goldfields/Eucla', 'Gascoyne', 'Central Wheat Belt', 'Interior', 'North Coast', 'South Coast', 'Northern Tablelands', 'Southern Tablelands', 'Northern Wheat/Sheep', 'Southern Wheat/Sheep', 'Western', 'North East', 'East Coast', 'Central North/Midlands/South East', 'Central Plateau/Derwent Valley', 'West/South Coast', 'North West', 'South East', 'Murray', 'Mid-North/Flinders', 'Pastoral', 'West Coast/Eyre', 'Mallee', 'Wimmera', 'Northern Country', 'North East Vic', 'East Gippsland', 'West/South Gippsland', 'Central', 'South West Vic', 'Central Highlands/Northern', 'Central West/Flinders', 'Channel Country', 'Maranoa/Warrego', 'Darling Downs/Burnett', 'North West/Gulf', 'Darwin-Daly', 'Arnhem-Roper', 'Victoria River-TennantCreek', 'Alice Springs')") + return value + + @field_validator('tree_species') + def tree_species_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Mixed species (Environmental Plantings)', 'No tree data available', 'Tasmanian Blue Gum', 'Spotted Gum', 'Sugar Gum', 'Hoop Pine', 'Sydney Blue Gum', 'Dunn\'s White Gum', 'Shining Gum', 'Pinus Radiata', 'Lemon-scented Gum', 'Maritime Pine', 'Flooded Gum', 'Red Ironbark', 'Radiata Pine (low input)', 'Mountain Ash', 'Western White Gum', 'Slash Pine', 'Radiata Pine (high input)', 'Pinus Radiata (low input)', 'Blackbutt', 'Loblolly Pine', 'Pinus Radiata (high input)', 'Pinus Hybrids']): + raise ValueError("must be one of enum values ('Mixed species (Environmental Plantings)', 'No tree data available', 'Tasmanian Blue Gum', 'Spotted Gum', 'Sugar Gum', 'Hoop Pine', 'Sydney Blue Gum', 'Dunn\'s White Gum', 'Shining Gum', 'Pinus Radiata', 'Lemon-scented Gum', 'Maritime Pine', 'Flooded Gum', 'Red Ironbark', 'Radiata Pine (low input)', 'Mountain Ash', 'Western White Gum', 'Slash Pine', 'Radiata Pine (high input)', 'Pinus Radiata (low input)', 'Blackbutt', 'Loblolly Pine', 'Pinus Radiata (high input)', 'Pinus Hybrids')") + return value + + @field_validator('soil') + def soil_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Loams & Clays', 'No Soil / Tree data available', 'Coloured Sands', 'Duplex', 'Clay', '\"Other Soils\"', 'Other Soils', 'Duplex Soils', 'Sandy Soils', 'Calcarosols', 'Grey Cracking Clays', 'Red Earths', 'Non-cracking Clays', 'Red Duplex', 'Cracking Clays', 'Clays', 'Clay Gidgee', 'Clay (Brigalo and Belah)', 'Kandosols', 'Sandy Duplexes', 'Clay & Red Loam', 'Loam', 'Structured Earths', 'Loamy Soils', 'Yellow Duplex', 'Gradational soils', 'Open Downs', 'Duplex Woodland', 'Earths', 'Tenosols']): + raise ValueError("must be one of enum values ('Loams & Clays', 'No Soil / Tree data available', 'Coloured Sands', 'Duplex', 'Clay', '\"Other Soils\"', 'Other Soils', 'Duplex Soils', 'Sandy Soils', 'Calcarosols', 'Grey Cracking Clays', 'Red Earths', 'Non-cracking Clays', 'Red Duplex', 'Cracking Clays', 'Clays', 'Clay Gidgee', 'Clay (Brigalo and Belah)', 'Kandosols', 'Sandy Duplexes', 'Clay & Red Loam', 'Loam', 'Structured Earths', 'Loamy Soils', 'Yellow Duplex', 'Gradational soils', 'Open Downs', 'Duplex Woodland', 'Earths', 'Tenosols')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBeefRequestVegetationInnerVegetation from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBeefRequestVegetationInnerVegetation from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "region": obj.get("region"), + "treeSpecies": obj.get("treeSpecies"), + "soil": obj.get("soil"), + "area": obj.get("area"), + "age": obj.get("age") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response.py new file mode 100644 index 00000000..48d819d3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_buffalo200_response_intensities import PostBuffalo200ResponseIntensities +from openapi_client.models.post_buffalo200_response_intermediate_inner import PostBuffalo200ResponseIntermediateInner +from openapi_client.models.post_buffalo200_response_net import PostBuffalo200ResponseNet +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200Response(BaseModel): + """ + Emissions calculation output for the `Buffalo` calculator + """ # noqa: E501 + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBuffalo200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + net: PostBuffalo200ResponseNet + intensities: PostBuffalo200ResponseIntensities + intermediate: List[PostBuffalo200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBuffalo200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostBuffalo200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostBuffalo200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "intermediate": [PostBuffalo200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intensities.py new file mode 100644 index 00000000..5cf6d98a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200ResponseIntensities(BaseModel): + """ + PostBuffalo200ResponseIntensities + """ # noqa: E501 + liveweight_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Amount of buffalo meat produced in kg liveweight", alias="liveweightProducedKg") + buffalo_meat_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Buffalo meat (breeding herd) excluding sequestration, in kg-CO2e/kg liveweight", alias="buffaloMeatExcludingSequestration") + buffalo_meat_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Buffalo meat (breeding herd) including sequestration, in kg-CO2e/kg liveweight", alias="buffaloMeatIncludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["liveweightProducedKg", "buffaloMeatExcludingSequestration", "buffaloMeatIncludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "liveweightProducedKg": obj.get("liveweightProducedKg"), + "buffaloMeatExcludingSequestration": obj.get("buffaloMeatExcludingSequestration"), + "buffaloMeatIncludingSequestration": obj.get("buffaloMeatIncludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intermediate_inner.py new file mode 100644 index 00000000..94e85262 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_buffalo200_response_intensities import PostBuffalo200ResponseIntensities +from openapi_client.models.post_buffalo200_response_net import PostBuffalo200ResponseNet +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Buffalo calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBuffalo200ResponseScope3 + net: PostBuffalo200ResponseNet + intensities: PostBuffalo200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "net", "intensities", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBuffalo200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "net": PostBuffalo200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostBuffalo200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_net.py new file mode 100644 index 00000000..f1264cb7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200ResponseNet(BaseModel): + """ + Net emissions for Buffalo + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope1.py new file mode 100644 index 00000000..42a6734b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope1.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + enteric_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from enteric fermentation, in tonnes-CO2e", alias="entericCH4") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + urine_and_dung_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from urine and dung, in tonnes-CO2e", alias="urineAndDungN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "fertiliserN2O", "entericCH4", "manureManagementCH4", "urineAndDungN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "entericCH4": obj.get("entericCH4"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "urineAndDungN2O": obj.get("urineAndDungN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope3.py new file mode 100644 index 00000000..5e0941ef --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo200_response_scope3.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffalo200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + purchased_feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased feed, in tonnes-CO2e", alias="purchasedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + purchased_livestock: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased livestock, in tonnes-CO2e", alias="purchasedLivestock") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "purchasedFeed", "herbicide", "electricity", "fuel", "lime", "purchasedLivestock", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffalo200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "purchasedFeed": obj.get("purchasedFeed"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "purchasedLivestock": obj.get("purchasedLivestock"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request.py new file mode 100644 index 00000000..db6e6e15 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_buffalo_request_buffalos_inner import PostBuffaloRequestBuffalosInner +from openapi_client.models.post_buffalo_request_vegetation_inner import PostBuffaloRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequest(BaseModel): + """ + Input data required for the `Buffalo` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + buffalos: List[PostBuffaloRequestBuffalosInner] + vegetation: List[PostBuffaloRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "rainfallAbove600", "buffalos", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in buffalos (list) + _items = [] + if self.buffalos: + for _item_buffalos in self.buffalos: + if _item_buffalos: + _items.append(_item_buffalos.to_dict()) + _dict['buffalos'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "buffalos": [PostBuffaloRequestBuffalosInner.from_dict(_item) for _item in obj["buffalos"]] if obj.get("buffalos") is not None else None, + "vegetation": [PostBuffaloRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner.py new file mode 100644 index 00000000..e0ecaf14 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_buffalo_request_buffalos_inner_classes import PostBuffaloRequestBuffalosInnerClasses +from openapi_client.models.post_buffalo_request_buffalos_inner_cows_calving import PostBuffaloRequestBuffalosInnerCowsCalving +from openapi_client.models.post_buffalo_request_buffalos_inner_seasonal_calving import PostBuffaloRequestBuffalosInnerSeasonalCalving +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInner(BaseModel): + """ + PostBuffaloRequestBuffalosInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostBuffaloRequestBuffalosInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + cows_calving: PostBuffaloRequestBuffalosInnerCowsCalving = Field(alias="cowsCalving") + seasonal_calving: PostBuffaloRequestBuffalosInnerSeasonalCalving = Field(alias="seasonalCalving") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "herbicide", "herbicideOther", "cowsCalving", "seasonalCalving"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of cows_calving + if self.cows_calving: + _dict['cowsCalving'] = self.cows_calving.to_dict() + # override the default output from pydantic by calling `to_dict()` of seasonal_calving + if self.seasonal_calving: + _dict['seasonalCalving'] = self.seasonal_calving.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostBuffaloRequestBuffalosInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "cowsCalving": PostBuffaloRequestBuffalosInnerCowsCalving.from_dict(obj["cowsCalving"]) if obj.get("cowsCalving") is not None else None, + "seasonalCalving": PostBuffaloRequestBuffalosInnerSeasonalCalving.from_dict(obj["seasonalCalving"]) if obj.get("seasonalCalving") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes.py new file mode 100644 index 00000000..6d7b1598 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes.py @@ -0,0 +1,147 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls import PostBuffaloRequestBuffalosInnerClassesBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_calfs import PostBuffaloRequestBuffalosInnerClassesCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_cows import PostBuffaloRequestBuffalosInnerClassesCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_steers import PostBuffaloRequestBuffalosInnerClassesSteers +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_bulls import PostBuffaloRequestBuffalosInnerClassesTradeBulls +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_calfs import PostBuffaloRequestBuffalosInnerClassesTradeCalfs +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_cows import PostBuffaloRequestBuffalosInnerClassesTradeCows +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_trade_steers import PostBuffaloRequestBuffalosInnerClassesTradeSteers +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClasses(BaseModel): + """ + Buffalo classes of different types + """ # noqa: E501 + bulls: Optional[PostBuffaloRequestBuffalosInnerClassesBulls] = None + trade_bulls: Optional[PostBuffaloRequestBuffalosInnerClassesTradeBulls] = Field(default=None, alias="tradeBulls") + cows: Optional[PostBuffaloRequestBuffalosInnerClassesCows] = None + trade_cows: Optional[PostBuffaloRequestBuffalosInnerClassesTradeCows] = Field(default=None, alias="tradeCows") + steers: Optional[PostBuffaloRequestBuffalosInnerClassesSteers] = None + trade_steers: Optional[PostBuffaloRequestBuffalosInnerClassesTradeSteers] = Field(default=None, alias="tradeSteers") + calfs: Optional[PostBuffaloRequestBuffalosInnerClassesCalfs] = None + trade_calfs: Optional[PostBuffaloRequestBuffalosInnerClassesTradeCalfs] = Field(default=None, alias="tradeCalfs") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bulls", "tradeBulls", "cows", "tradeCows", "steers", "tradeSteers", "calfs", "tradeCalfs"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of bulls + if self.bulls: + _dict['bulls'] = self.bulls.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_bulls + if self.trade_bulls: + _dict['tradeBulls'] = self.trade_bulls.to_dict() + # override the default output from pydantic by calling `to_dict()` of cows + if self.cows: + _dict['cows'] = self.cows.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_cows + if self.trade_cows: + _dict['tradeCows'] = self.trade_cows.to_dict() + # override the default output from pydantic by calling `to_dict()` of steers + if self.steers: + _dict['steers'] = self.steers.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_steers + if self.trade_steers: + _dict['tradeSteers'] = self.trade_steers.to_dict() + # override the default output from pydantic by calling `to_dict()` of calfs + if self.calfs: + _dict['calfs'] = self.calfs.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_calfs + if self.trade_calfs: + _dict['tradeCalfs'] = self.trade_calfs.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bulls": PostBuffaloRequestBuffalosInnerClassesBulls.from_dict(obj["bulls"]) if obj.get("bulls") is not None else None, + "tradeBulls": PostBuffaloRequestBuffalosInnerClassesTradeBulls.from_dict(obj["tradeBulls"]) if obj.get("tradeBulls") is not None else None, + "cows": PostBuffaloRequestBuffalosInnerClassesCows.from_dict(obj["cows"]) if obj.get("cows") is not None else None, + "tradeCows": PostBuffaloRequestBuffalosInnerClassesTradeCows.from_dict(obj["tradeCows"]) if obj.get("tradeCows") is not None else None, + "steers": PostBuffaloRequestBuffalosInnerClassesSteers.from_dict(obj["steers"]) if obj.get("steers") is not None else None, + "tradeSteers": PostBuffaloRequestBuffalosInnerClassesTradeSteers.from_dict(obj["tradeSteers"]) if obj.get("tradeSteers") is not None else None, + "calfs": PostBuffaloRequestBuffalosInnerClassesCalfs.from_dict(obj["calfs"]) if obj.get("calfs") is not None else None, + "tradeCalfs": PostBuffaloRequestBuffalosInnerClassesTradeCalfs.from_dict(obj["tradeCalfs"]) if obj.get("tradeCalfs") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls.py new file mode 100644 index 00000000..ee3decda --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesBulls(BaseModel): + """ + Bulls + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBulls from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBulls from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_autumn.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_autumn.py new file mode 100644 index 00000000..f51779cb --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_autumn.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesBullsAutumn(BaseModel): + """ + PostBuffaloRequestBuffalosInnerClassesBullsAutumn + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals (head)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBullsAutumn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBullsAutumn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner.py new file mode 100644 index 00000000..004471a0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner(BaseModel): + """ + PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_calfs.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_calfs.py new file mode 100644 index 00000000..48df6e63 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_calfs.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesCalfs(BaseModel): + """ + Calfs + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesCalfs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesCalfs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_cows.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_cows.py new file mode 100644 index 00000000..d6a7c252 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_cows.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesCows(BaseModel): + """ + Cows + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesCows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesCows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_steers.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_steers.py new file mode 100644 index 00000000..735d9c76 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_steers.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesSteers(BaseModel): + """ + Steers + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesSteers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesSteers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_bulls.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_bulls.py new file mode 100644 index 00000000..d7d66517 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_bulls.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesTradeBulls(BaseModel): + """ + Trade bulls + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeBulls from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeBulls from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_calfs.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_calfs.py new file mode 100644 index 00000000..5bfea3ca --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_calfs.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesTradeCalfs(BaseModel): + """ + Trade calfs + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeCalfs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeCalfs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_cows.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_cows.py new file mode 100644 index 00000000..0133349c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_cows.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesTradeCows(BaseModel): + """ + Trade cows + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeCows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeCows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_steers.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_steers.py new file mode 100644 index 00000000..c59e9228 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_classes_trade_steers.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerClassesTradeSteers(BaseModel): + """ + Trade steers + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeSteers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerClassesTradeSteers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_cows_calving.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_cows_calving.py new file mode 100644 index 00000000..bea5e22f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_cows_calving.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerCowsCalving(BaseModel): + """ + Proportion of cows calving in each season, from 0 to 1 + """ # noqa: E501 + spring: Union[StrictFloat, StrictInt] + summer: Union[StrictFloat, StrictInt] + autumn: Union[StrictFloat, StrictInt] + winter: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerCowsCalving from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerCowsCalving from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "autumn": obj.get("autumn"), + "winter": obj.get("winter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_seasonal_calving.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_seasonal_calving.py new file mode 100644 index 00000000..2b9aa014 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_buffalos_inner_seasonal_calving.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestBuffalosInnerSeasonalCalving(BaseModel): + """ + Seasonal calving rates, from 0 to 1 + """ # noqa: E501 + spring: Union[StrictFloat, StrictInt] + summer: Union[StrictFloat, StrictInt] + autumn: Union[StrictFloat, StrictInt] + winter: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerSeasonalCalving from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestBuffalosInnerSeasonalCalving from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "autumn": obj.get("autumn"), + "winter": obj.get("winter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_vegetation_inner.py new file mode 100644 index 00000000..1c0a213d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_buffalo_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostBuffaloRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to Buffalo + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + buffalo_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to Buffalo", alias="buffaloProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "buffaloProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostBuffaloRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostBuffaloRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "buffaloProportion": obj.get("buffaloProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response.py new file mode 100644 index 00000000..b02d4803 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_intermediate_inner import PostCotton200ResponseIntermediateInner +from openapi_client.models.post_cotton200_response_intermediate_inner_intensities import PostCotton200ResponseIntermediateInnerIntensities +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200Response(BaseModel): + """ + Emissions calculation output for the `cotton` calculator + """ # noqa: E501 + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostCotton200ResponseIntermediateInner] + net: PostCotton200ResponseNet + intensities: List[PostCotton200ResponseIntermediateInnerIntensities] = Field(description="Emissions intensity for each crop (in order)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostCotton200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostCotton200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostCotton200ResponseIntermediateInnerIntensities.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner.py new file mode 100644 index 00000000..9f8e4bc4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_intermediate_inner_intensities import PostCotton200ResponseIntermediateInnerIntensities +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Cotton calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + intensities: PostCotton200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "intensities", "net", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "intensities": PostCotton200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..64f70f21 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_intermediate_inner_intensities.py @@ -0,0 +1,127 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200ResponseIntermediateInnerIntensities(BaseModel): + """ + Cotton intensities output + """ # noqa: E501 + cotton_yield_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Cotton yield produced in tonnes", alias="cottonYieldProducedTonnes") + bales_produced: Union[StrictFloat, StrictInt] = Field(description="Number of bales produced", alias="balesProduced") + lint_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Cotton lint produced in tonnes", alias="lintProducedTonnes") + seed_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Cotton seed produced in tonnes", alias="seedProducedTonnes") + tonnes_crop_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity excluding sequestration, in t-CO2e/t crop", alias="tonnesCropExcludingSequestration") + tonnes_crop_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity including sequestration, in t-CO2e/t crop", alias="tonnesCropIncludingSequestration") + bales_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity excluding sequestration, in t-CO2e/bale", alias="balesExcludingSequestration") + bales_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity including sequestration, in t-CO2e/bale", alias="balesIncludingSequestration") + lint_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of lint including sequestration, in t-CO2e/kg", alias="lintIncludingSequestration") + lint_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of lint excluding sequestration, in t-CO2e/kg", alias="lintExcludingSequestration") + seed_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of seed including sequestration, in t-CO2e/kg", alias="seedIncludingSequestration") + seed_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of seed excluding sequestration, in t-CO2e/kg", alias="seedExcludingSequestration") + lint_economic_allocation: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of lint using economic allocation, in t-CO2e/kg", alias="lintEconomicAllocation") + seed_economic_allocation: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of seed using economic allocation, in t-CO2e/kg", alias="seedEconomicAllocation") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["cottonYieldProducedTonnes", "balesProduced", "lintProducedTonnes", "seedProducedTonnes", "tonnesCropExcludingSequestration", "tonnesCropIncludingSequestration", "balesExcludingSequestration", "balesIncludingSequestration", "lintIncludingSequestration", "lintExcludingSequestration", "seedIncludingSequestration", "seedExcludingSequestration", "lintEconomicAllocation", "seedEconomicAllocation"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cottonYieldProducedTonnes": obj.get("cottonYieldProducedTonnes"), + "balesProduced": obj.get("balesProduced"), + "lintProducedTonnes": obj.get("lintProducedTonnes"), + "seedProducedTonnes": obj.get("seedProducedTonnes"), + "tonnesCropExcludingSequestration": obj.get("tonnesCropExcludingSequestration"), + "tonnesCropIncludingSequestration": obj.get("tonnesCropIncludingSequestration"), + "balesExcludingSequestration": obj.get("balesExcludingSequestration"), + "balesIncludingSequestration": obj.get("balesIncludingSequestration"), + "lintIncludingSequestration": obj.get("lintIncludingSequestration"), + "lintExcludingSequestration": obj.get("lintExcludingSequestration"), + "seedIncludingSequestration": obj.get("seedIncludingSequestration"), + "seedExcludingSequestration": obj.get("seedExcludingSequestration"), + "lintEconomicAllocation": obj.get("lintEconomicAllocation"), + "seedEconomicAllocation": obj.get("seedEconomicAllocation") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_net.py new file mode 100644 index 00000000..99f7dca8 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_net.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200ResponseNet(BaseModel): + """ + Net emissions for each crop (in order) + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + crops: List[Union[StrictFloat, StrictInt]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "crops"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "crops": obj.get("crops") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope1.py new file mode 100644 index 00000000..631ca2bf --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope1.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + crop_residue_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from crop residue, in tonnes-CO2e", alias="cropResidueN2O") + field_burning_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from field burning, in tonnes-CO2e", alias="fieldBurningN2O") + field_burning_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from field burning, in tonnes-CO2e", alias="fieldBurningCH4") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "fertiliserN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "cropResidueN2O", "fieldBurningN2O", "fieldBurningCH4", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "cropResidueN2O": obj.get("cropResidueN2O"), + "fieldBurningN2O": obj.get("fieldBurningN2O"), + "fieldBurningCH4": obj.get("fieldBurningCH4"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope3.py new file mode 100644 index 00000000..5e0ca11b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton200_response_scope3.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostCotton200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "herbicide", "electricity", "fuel", "lime", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCotton200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCotton200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton_request.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request.py new file mode 100644 index 00000000..d3ddd1ce --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_cotton_request_crops_inner import PostCottonRequestCropsInner +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostCottonRequest(BaseModel): + """ + Input data required for the `cotton` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + crops: List[PostCottonRequestCropsInner] + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + vegetation: List[PostCottonRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "crops", "electricityRenewable", "electricityUse", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCottonRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in crops (list) + _items = [] + if self.crops: + for _item_crops in self.crops: + if _item_crops: + _items.append(_item_crops.to_dict()) + _dict['crops'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCottonRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "crops": [PostCottonRequestCropsInner.from_dict(_item) for _item in obj["crops"]] if obj.get("crops") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "vegetation": [PostCottonRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_crops_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_crops_inner.py new file mode 100644 index 00000000..77d82e2d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_crops_inner.py @@ -0,0 +1,170 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostCottonRequestCropsInner(BaseModel): + """ + PostCottonRequestCropsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + average_cotton_yield: Union[StrictFloat, StrictInt] = Field(description="Average cotton yield, in t/ha (tonnes per hectare)", alias="averageCottonYield") + area_sown: Union[StrictFloat, StrictInt] = Field(description="Area sown, in ha (hectares)", alias="areaSown") + average_weight_per_bale_kg: Union[StrictFloat, StrictInt] = Field(description="Average weight of unprocessed cotton per bale, in kg", alias="averageWeightPerBaleKg") + cotton_lint_per_bale_kg: Union[StrictFloat, StrictInt] = Field(description="Average weight of cotton lint per bale, in kg", alias="cottonLintPerBaleKg") + cotton_seed_per_bale_kg: Union[StrictFloat, StrictInt] = Field(description="Average weight of cotton seed produced per bale, in kg", alias="cottonSeedPerBaleKg") + waste_per_bale_kg: Union[StrictFloat, StrictInt] = Field(description="Average weight of cotton waste produced per bale, in kg", alias="wastePerBaleKg") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + other_fertiliser_type: Optional[StrictStr] = Field(default=None, description="Other N fertiliser type", alias="otherFertiliserType") + other_fertiliser_application: Union[StrictFloat, StrictInt] = Field(description="Other N fertiliser application, in kg/ha (kilograms per hectare)", alias="otherFertiliserApplication") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + single_super_phosphate: Union[StrictFloat, StrictInt] = Field(description="Single superphosphate use, in kg/ha (kilograms per hectare)", alias="singleSuperPhosphate") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm", alias="rainfallAbove600") + fraction_of_annual_crop_burnt: Union[StrictFloat, StrictInt] = Field(description="Fraction of annual production of crop that is burnt. If included, this should only ever be 0 for cotton", alias="fractionOfAnnualCropBurnt") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_allocation: Union[StrictFloat, StrictInt] = Field(description="Percentage of electricity use to allocate to this crop, from 0 to 1", alias="electricityAllocation") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + diesel_use: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)", alias="dieselUse") + petrol_use: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)", alias="petrolUse") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "averageCottonYield", "areaSown", "averageWeightPerBaleKg", "cottonLintPerBaleKg", "cottonSeedPerBaleKg", "wastePerBaleKg", "ureaApplication", "otherFertiliserType", "otherFertiliserApplication", "nonUreaNitrogen", "ureaAmmoniumNitrate", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "singleSuperPhosphate", "rainfallAbove600", "fractionOfAnnualCropBurnt", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityAllocation", "limestone", "limestoneFraction", "dieselUse", "petrolUse", "lpg"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('other_fertiliser_type') + def other_fertiliser_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia']): + raise ValueError("must be one of enum values ('Monoammonium phosphate (MAP)', 'Diammonium Phosphate (DAP)', 'Urea-Ammonium Nitrate (UAN)', 'Ammonium Nitrate (AN)', 'Calcium Ammonium Nitrate (CAN)', 'Triple Superphosphate (TSP)', 'Super Potash 1:1', 'Super Potash 2:1', 'Super Potash 3:1', 'Super Potash 4:1', 'Super Potash 5:1', 'Muriate of Potash', 'Sulphate of Potash', 'Sulphate of Ammonia')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCottonRequestCropsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCottonRequestCropsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "averageCottonYield": obj.get("averageCottonYield"), + "areaSown": obj.get("areaSown"), + "averageWeightPerBaleKg": obj.get("averageWeightPerBaleKg"), + "cottonLintPerBaleKg": obj.get("cottonLintPerBaleKg"), + "cottonSeedPerBaleKg": obj.get("cottonSeedPerBaleKg"), + "wastePerBaleKg": obj.get("wastePerBaleKg"), + "ureaApplication": obj.get("ureaApplication"), + "otherFertiliserType": obj.get("otherFertiliserType"), + "otherFertiliserApplication": obj.get("otherFertiliserApplication"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen") if obj.get("nonUreaNitrogen") is not None else 0, + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate") if obj.get("ureaAmmoniumNitrate") is not None else 0, + "phosphorusApplication": obj.get("phosphorusApplication") if obj.get("phosphorusApplication") is not None else 0, + "potassiumApplication": obj.get("potassiumApplication") if obj.get("potassiumApplication") is not None else 0, + "sulfurApplication": obj.get("sulfurApplication") if obj.get("sulfurApplication") is not None else 0, + "singleSuperPhosphate": obj.get("singleSuperPhosphate"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "fractionOfAnnualCropBurnt": obj.get("fractionOfAnnualCropBurnt") if obj.get("fractionOfAnnualCropBurnt") is not None else 0, + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityAllocation": obj.get("electricityAllocation"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "dieselUse": obj.get("dieselUse"), + "petrolUse": obj.get("petrolUse"), + "lpg": obj.get("lpg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_vegetation_inner.py new file mode 100644 index 00000000..3f2008a2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_cotton_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostCottonRequestVegetationInner(BaseModel): + """ + PostCottonRequestVegetationInner + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + allocation_to_crops: List[Union[StrictFloat, StrictInt]] = Field(alias="allocationToCrops") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "allocationToCrops"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostCottonRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostCottonRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "allocationToCrops": obj.get("allocationToCrops") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response.py new file mode 100644 index 00000000..e008f156 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_dairy200_response_intensities import PostDairy200ResponseIntensities +from openapi_client.models.post_dairy200_response_intermediate_inner import PostDairy200ResponseIntermediateInner +from openapi_client.models.post_dairy200_response_net import PostDairy200ResponseNet +from openapi_client.models.post_dairy200_response_scope1 import PostDairy200ResponseScope1 +from openapi_client.models.post_dairy200_response_scope3 import PostDairy200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200Response(BaseModel): + """ + Emissions calculation output for the `dairy` calculator + """ # noqa: E501 + scope1: PostDairy200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostDairy200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + net: PostDairy200ResponseNet + intensities: PostDairy200ResponseIntensities + intermediate: List[PostDairy200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostDairy200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostDairy200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostDairy200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostDairy200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "intermediate": [PostDairy200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intensities.py new file mode 100644 index 00000000..1761a9c1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intensities.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200ResponseIntensities(BaseModel): + """ + PostDairy200ResponseIntensities + """ # noqa: E501 + milk_solids_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Milk solids produced in tonnes", alias="milkSolidsProducedTonnes") + intensity: Union[StrictFloat, StrictInt] = Field(description="Dairy intensities including carbon sequestration, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["milkSolidsProducedTonnes", "intensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "milkSolidsProducedTonnes": obj.get("milkSolidsProducedTonnes"), + "intensity": obj.get("intensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intermediate_inner.py new file mode 100644 index 00000000..e4b939a1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_dairy200_response_intensities import PostDairy200ResponseIntensities +from openapi_client.models.post_dairy200_response_net import PostDairy200ResponseNet +from openapi_client.models.post_dairy200_response_scope1 import PostDairy200ResponseScope1 +from openapi_client.models.post_dairy200_response_scope3 import PostDairy200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Dairy calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostDairy200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostDairy200ResponseScope3 + net: PostDairy200ResponseNet + intensities: PostDairy200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "net", "intensities", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostDairy200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostDairy200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "net": PostDairy200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostDairy200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_net.py new file mode 100644 index 00000000..d157ad1b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200ResponseNet(BaseModel): + """ + PostDairy200ResponseNet + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Total net emissions of this activity, in tonnes-CO2e/year") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope1.py new file mode 100644 index 00000000..9defa0f8 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope1.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + enteric_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from enteric fermentation, in tonnes-CO2e", alias="entericCH4") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + manure_management_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from manure management, in tonnes-CO2e", alias="manureManagementN2O") + animal_waste_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from animal waste, in tonnes-CO2e", alias="animalWasteN2O") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + urine_and_dung_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from urine and dung, in tonnes-CO2e", alias="urineAndDungN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + transport_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from transport, in tonnes-CO2e", alias="transportN2O") + transport_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from transport, in tonnes-CO2e", alias="transportCH4") + transport_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from transport, in tonnes-CO2e", alias="transportCO2") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "entericCH4", "manureManagementCH4", "manureManagementN2O", "animalWasteN2O", "fertiliserN2O", "urineAndDungN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "transportN2O", "transportCH4", "transportCO2", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "entericCH4": obj.get("entericCH4"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "manureManagementN2O": obj.get("manureManagementN2O"), + "animalWasteN2O": obj.get("animalWasteN2O"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "urineAndDungN2O": obj.get("urineAndDungN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "transportN2O": obj.get("transportN2O"), + "transportCH4": obj.get("transportCH4"), + "transportCO2": obj.get("transportCO2"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope3.py new file mode 100644 index 00000000..045ae7c0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy200_response_scope3.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairy200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + purchased_feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased feed, in tonnes-CO2e", alias="purchasedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "purchasedFeed", "herbicide", "electricity", "fuel", "lime", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairy200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairy200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "purchasedFeed": obj.get("purchasedFeed"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request.py new file mode 100644 index 00000000..fe1e6740 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner import PostDairyRequestDairyInner +from openapi_client.models.post_dairy_request_vegetation_inner import PostDairyRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequest(BaseModel): + """ + Input data required for the `dairy` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + production_system: StrictStr = Field(description="Production system", alias="productionSystem") + dairy: List[PostDairyRequestDairyInner] + vegetation: List[PostDairyRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "rainfallAbove600", "productionSystem", "dairy", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('production_system') + def production_system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Non-irrigated Crop', 'Irrigated Crop', 'Irrigated Pasture', 'Non-irrigated Pasture']): + raise ValueError("must be one of enum values ('Non-irrigated Crop', 'Irrigated Crop', 'Irrigated Pasture', 'Non-irrigated Pasture')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in dairy (list) + _items = [] + if self.dairy: + for _item_dairy in self.dairy: + if _item_dairy: + _items.append(_item_dairy.to_dict()) + _dict['dairy'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "productionSystem": obj.get("productionSystem"), + "dairy": [PostDairyRequestDairyInner.from_dict(_item) for _item in obj["dairy"]] if obj.get("dairy") is not None else None, + "vegetation": [PostDairyRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner.py new file mode 100644 index 00000000..a838fbbb --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner.py @@ -0,0 +1,174 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_dairy_request_dairy_inner_areas import PostDairyRequestDairyInnerAreas +from openapi_client.models.post_dairy_request_dairy_inner_classes import PostDairyRequestDairyInnerClasses +from openapi_client.models.post_dairy_request_dairy_inner_manure_management_milking_cows import PostDairyRequestDairyInnerManureManagementMilkingCows +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser import PostDairyRequestDairyInnerSeasonalFertiliser +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInner(BaseModel): + """ + PostDairyRequestDairyInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostDairyRequestDairyInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + seasonal_fertiliser: PostDairyRequestDairyInnerSeasonalFertiliser = Field(alias="seasonalFertiliser") + areas: PostDairyRequestDairyInnerAreas + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + cottonseed_feed: Union[StrictFloat, StrictInt] = Field(description="Cotton seed purchased for cattle feed in tonnes", alias="cottonseedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + manure_management_milking_cows: PostDairyRequestDairyInnerManureManagementMilkingCows = Field(alias="manureManagementMilkingCows") + manure_management_other_dairy_cows: PostDairyRequestDairyInnerManureManagementMilkingCows = Field(alias="manureManagementOtherDairyCows") + emissions_allocation_to_red_meat_production: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Allocation as a fraction, from 0 to 1", alias="emissionsAllocationToRedMeatProduction") + truck_type: StrictStr = Field(description="Type of truck used for cattle transport", alias="truckType") + distance_cattle_transported: Union[StrictFloat, StrictInt] = Field(description="Distance cattle are transported between farms, in km (kilometres)", alias="distanceCattleTransported") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "seasonalFertiliser", "areas", "diesel", "petrol", "lpg", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "cottonseedFeed", "herbicide", "herbicideOther", "manureManagementMilkingCows", "manureManagementOtherDairyCows", "emissionsAllocationToRedMeatProduction", "truckType", "distanceCattleTransported"] + + @field_validator('truck_type') + def truck_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['4 Deck Trailer', '6 Deck Trailer', 'B-Double']): + raise ValueError("must be one of enum values ('4 Deck Trailer', '6 Deck Trailer', 'B-Double')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of seasonal_fertiliser + if self.seasonal_fertiliser: + _dict['seasonalFertiliser'] = self.seasonal_fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of areas + if self.areas: + _dict['areas'] = self.areas.to_dict() + # override the default output from pydantic by calling `to_dict()` of manure_management_milking_cows + if self.manure_management_milking_cows: + _dict['manureManagementMilkingCows'] = self.manure_management_milking_cows.to_dict() + # override the default output from pydantic by calling `to_dict()` of manure_management_other_dairy_cows + if self.manure_management_other_dairy_cows: + _dict['manureManagementOtherDairyCows'] = self.manure_management_other_dairy_cows.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostDairyRequestDairyInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "seasonalFertiliser": PostDairyRequestDairyInnerSeasonalFertiliser.from_dict(obj["seasonalFertiliser"]) if obj.get("seasonalFertiliser") is not None else None, + "areas": PostDairyRequestDairyInnerAreas.from_dict(obj["areas"]) if obj.get("areas") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "cottonseedFeed": obj.get("cottonseedFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "manureManagementMilkingCows": PostDairyRequestDairyInnerManureManagementMilkingCows.from_dict(obj["manureManagementMilkingCows"]) if obj.get("manureManagementMilkingCows") is not None else None, + "manureManagementOtherDairyCows": PostDairyRequestDairyInnerManureManagementMilkingCows.from_dict(obj["manureManagementOtherDairyCows"]) if obj.get("manureManagementOtherDairyCows") is not None else None, + "emissionsAllocationToRedMeatProduction": obj.get("emissionsAllocationToRedMeatProduction"), + "truckType": obj.get("truckType"), + "distanceCattleTransported": obj.get("distanceCattleTransported") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_areas.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_areas.py new file mode 100644 index 00000000..5a40491b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_areas.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerAreas(BaseModel): + """ + Areas in hectares (ha) + """ # noqa: E501 + cropped_dryland: Union[StrictFloat, StrictInt] = Field(alias="croppedDryland") + cropped_irrigated: Union[StrictFloat, StrictInt] = Field(alias="croppedIrrigated") + improved_pasture_dryland: Union[StrictFloat, StrictInt] = Field(alias="improvedPastureDryland") + improved_pasture_irrigated: Union[StrictFloat, StrictInt] = Field(alias="improvedPastureIrrigated") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["croppedDryland", "croppedIrrigated", "improvedPastureDryland", "improvedPastureIrrigated"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerAreas from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerAreas from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "croppedDryland": obj.get("croppedDryland") if obj.get("croppedDryland") is not None else 0, + "croppedIrrigated": obj.get("croppedIrrigated") if obj.get("croppedIrrigated") is not None else 0, + "improvedPastureDryland": obj.get("improvedPastureDryland") if obj.get("improvedPastureDryland") is not None else 0, + "improvedPastureIrrigated": obj.get("improvedPastureIrrigated") if obj.get("improvedPastureIrrigated") is not None else 0 + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes.py new file mode 100644 index 00000000..f0c688c2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_gt1 import PostDairyRequestDairyInnerClassesDairyBullsGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_dairy_bulls_lt1 import PostDairyRequestDairyInnerClassesDairyBullsLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_gt1 import PostDairyRequestDairyInnerClassesHeifersGt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_heifers_lt1 import PostDairyRequestDairyInnerClassesHeifersLt1 +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows import PostDairyRequestDairyInnerClassesMilkingCows +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClasses(BaseModel): + """ + Dairy classes of different types and age ranges + """ # noqa: E501 + milking_cows: PostDairyRequestDairyInnerClassesMilkingCows = Field(alias="milkingCows") + heifers_lt1: PostDairyRequestDairyInnerClassesHeifersLt1 = Field(alias="heifersLt1") + heifers_gt1: PostDairyRequestDairyInnerClassesHeifersGt1 = Field(alias="heifersGt1") + dairy_bulls_lt1: PostDairyRequestDairyInnerClassesDairyBullsLt1 = Field(alias="dairyBullsLt1") + dairy_bulls_gt1: PostDairyRequestDairyInnerClassesDairyBullsGt1 = Field(alias="dairyBullsGt1") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["milkingCows", "heifersLt1", "heifersGt1", "dairyBullsLt1", "dairyBullsGt1"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of milking_cows + if self.milking_cows: + _dict['milkingCows'] = self.milking_cows.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_lt1 + if self.heifers_lt1: + _dict['heifersLt1'] = self.heifers_lt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of heifers_gt1 + if self.heifers_gt1: + _dict['heifersGt1'] = self.heifers_gt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of dairy_bulls_lt1 + if self.dairy_bulls_lt1: + _dict['dairyBullsLt1'] = self.dairy_bulls_lt1.to_dict() + # override the default output from pydantic by calling `to_dict()` of dairy_bulls_gt1 + if self.dairy_bulls_gt1: + _dict['dairyBullsGt1'] = self.dairy_bulls_gt1.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "milkingCows": PostDairyRequestDairyInnerClassesMilkingCows.from_dict(obj["milkingCows"]) if obj.get("milkingCows") is not None else None, + "heifersLt1": PostDairyRequestDairyInnerClassesHeifersLt1.from_dict(obj["heifersLt1"]) if obj.get("heifersLt1") is not None else None, + "heifersGt1": PostDairyRequestDairyInnerClassesHeifersGt1.from_dict(obj["heifersGt1"]) if obj.get("heifersGt1") is not None else None, + "dairyBullsLt1": PostDairyRequestDairyInnerClassesDairyBullsLt1.from_dict(obj["dairyBullsLt1"]) if obj.get("dairyBullsLt1") is not None else None, + "dairyBullsGt1": PostDairyRequestDairyInnerClassesDairyBullsGt1.from_dict(obj["dairyBullsGt1"]) if obj.get("dairyBullsGt1") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_gt1.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_gt1.py new file mode 100644 index 00000000..ef68e970 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_gt1.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesDairyBullsGt1(BaseModel): + """ + Dairy bulls whose age is greater than 1 year old + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + winter: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + spring: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + summer: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesDairyBullsGt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesDairyBullsGt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_lt1.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_lt1.py new file mode 100644 index 00000000..77f71a07 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_dairy_bulls_lt1.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesDairyBullsLt1(BaseModel): + """ + Dairy bulls whose age is less than 1 year old + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + winter: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + spring: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + summer: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesDairyBullsLt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesDairyBullsLt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_gt1.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_gt1.py new file mode 100644 index 00000000..0682e879 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_gt1.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesHeifersGt1(BaseModel): + """ + Heifers whose age is greater than 1 year old + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + winter: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + spring: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + summer: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesHeifersGt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesHeifersGt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_lt1.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_lt1.py new file mode 100644 index 00000000..3b5fd051 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_heifers_lt1.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesHeifersLt1(BaseModel): + """ + Heifers whose age is less than 1 year old + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + winter: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + spring: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + summer: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesHeifersLt1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesHeifersLt1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows.py new file mode 100644 index 00000000..ac8f13b7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_classes_milking_cows_autumn import PostDairyRequestDairyInnerClassesMilkingCowsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesMilkingCows(BaseModel): + """ + Milking cows + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + winter: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + spring: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + summer: PostDairyRequestDairyInnerClassesMilkingCowsAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesMilkingCows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesMilkingCows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerClassesMilkingCowsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows_autumn.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows_autumn.py new file mode 100644 index 00000000..bbf46cbf --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_classes_milking_cows_autumn.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerClassesMilkingCowsAutumn(BaseModel): + """ + PostDairyRequestDairyInnerClassesMilkingCowsAutumn + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals (head)") + liveweight: Union[StrictFloat, StrictInt] = Field(description="Average liveweight of animals in kg/head (kilogram per head)") + liveweight_gain: Union[StrictFloat, StrictInt] = Field(description="Average liveweight gain in kg/day (kilogram per day)", alias="liveweightGain") + crude_protein: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Crude protein percent, between 0 and 100. Note: If no value is provided, zero will be assumed. This will result in large, negative output values. This input will become mandatory in a future version.", alias="crudeProtein") + dry_matter_digestibility: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Dry matter digestibility percent, between 0 and 100. Note: If no value is provided, zero will be assumed. This will result in large, negative output values. This input will become mandatory in a future version.", alias="dryMatterDigestibility") + milk_production: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Milk produced in L/day/head (litres per day per head)", alias="milkProduction") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "liveweight", "liveweightGain", "crudeProtein", "dryMatterDigestibility", "milkProduction"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesMilkingCowsAutumn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerClassesMilkingCowsAutumn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "liveweight": obj.get("liveweight"), + "liveweightGain": obj.get("liveweightGain"), + "crudeProtein": obj.get("crudeProtein"), + "dryMatterDigestibility": obj.get("dryMatterDigestibility"), + "milkProduction": obj.get("milkProduction") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_manure_management_milking_cows.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_manure_management_milking_cows.py new file mode 100644 index 00000000..0c475e35 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_manure_management_milking_cows.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerManureManagementMilkingCows(BaseModel): + """ + Manure management for each type, each value is a percentage of all excreta, from 0 to 100 + """ # noqa: E501 + pasture: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] + anaerobic_lagoon: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(alias="anaerobicLagoon") + sump_and_dispersal: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(alias="sumpAndDispersal") + drain_to_paddocks: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(alias="drainToPaddocks") + soild_storage: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(alias="soildStorage") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["pasture", "anaerobicLagoon", "sumpAndDispersal", "drainToPaddocks", "soildStorage"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerManureManagementMilkingCows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerManureManagementMilkingCows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "pasture": obj.get("pasture"), + "anaerobicLagoon": obj.get("anaerobicLagoon"), + "sumpAndDispersal": obj.get("sumpAndDispersal"), + "drainToPaddocks": obj.get("drainToPaddocks"), + "soildStorage": obj.get("soildStorage") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser.py new file mode 100644 index 00000000..2e106946 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_dairy_request_dairy_inner_seasonal_fertiliser_autumn import PostDairyRequestDairyInnerSeasonalFertiliserAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerSeasonalFertiliser(BaseModel): + """ + Seasonal nitrogen fertiliser use + """ # noqa: E501 + autumn: PostDairyRequestDairyInnerSeasonalFertiliserAutumn + winter: PostDairyRequestDairyInnerSeasonalFertiliserAutumn + spring: PostDairyRequestDairyInnerSeasonalFertiliserAutumn + summer: PostDairyRequestDairyInnerSeasonalFertiliserAutumn + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerSeasonalFertiliser from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerSeasonalFertiliser from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostDairyRequestDairyInnerSeasonalFertiliserAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostDairyRequestDairyInnerSeasonalFertiliserAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostDairyRequestDairyInnerSeasonalFertiliserAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostDairyRequestDairyInnerSeasonalFertiliserAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser_autumn.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser_autumn.py new file mode 100644 index 00000000..a94bee08 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_dairy_inner_seasonal_fertiliser_autumn.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestDairyInnerSeasonalFertiliserAutumn(BaseModel): + """ + Nitrogen fertiliser application, each value is in kg N/ha + """ # noqa: E501 + crops_irrigated: Union[StrictFloat, StrictInt] = Field(alias="cropsIrrigated") + crops_dryland: Union[StrictFloat, StrictInt] = Field(alias="cropsDryland") + pasture_irrigated: Union[StrictFloat, StrictInt] = Field(alias="pastureIrrigated") + pasture_dryland: Union[StrictFloat, StrictInt] = Field(alias="pastureDryland") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["cropsIrrigated", "cropsDryland", "pastureIrrigated", "pastureDryland"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerSeasonalFertiliserAutumn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestDairyInnerSeasonalFertiliserAutumn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cropsIrrigated": obj.get("cropsIrrigated"), + "cropsDryland": obj.get("cropsDryland"), + "pastureIrrigated": obj.get("pastureIrrigated"), + "pastureDryland": obj.get("pastureDryland") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_vegetation_inner.py new file mode 100644 index 00000000..03c5cf75 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_dairy_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostDairyRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to dairy + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + dairy_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to dairy", alias="dairyProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "dairyProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDairyRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDairyRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "dairyProportion": obj.get("dairyProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response.py new file mode 100644 index 00000000..78fc9588 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 +from openapi_client.models.post_deer200_response_intensities import PostDeer200ResponseIntensities +from openapi_client.models.post_deer200_response_intermediate_inner import PostDeer200ResponseIntermediateInner +from openapi_client.models.post_deer200_response_net import PostDeer200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostDeer200Response(BaseModel): + """ + Emissions calculation output for the `deer` calculator + """ # noqa: E501 + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBuffalo200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + net: PostDeer200ResponseNet + intensities: PostDeer200ResponseIntensities + intermediate: List[PostDeer200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeer200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeer200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBuffalo200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostDeer200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostDeer200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "intermediate": [PostDeer200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intensities.py new file mode 100644 index 00000000..e0d6a752 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDeer200ResponseIntensities(BaseModel): + """ + PostDeer200ResponseIntensities + """ # noqa: E501 + liveweight_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Deer meat produced in kg liveweight", alias="liveweightProducedKg") + deer_meat_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Deer meat (breeding herd) excluding sequestration, in kg-CO2e/kg liveweight", alias="deerMeatExcludingSequestration") + deer_meat_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Deer meat (breeding herd) including sequestration, in kg-CO2e/kg liveweight", alias="deerMeatIncludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["liveweightProducedKg", "deerMeatExcludingSequestration", "deerMeatIncludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeer200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeer200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "liveweightProducedKg": obj.get("liveweightProducedKg"), + "deerMeatExcludingSequestration": obj.get("deerMeatExcludingSequestration"), + "deerMeatIncludingSequestration": obj.get("deerMeatIncludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intermediate_inner.py new file mode 100644 index 00000000..6a870d33 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_buffalo200_response_scope3 import PostBuffalo200ResponseScope3 +from openapi_client.models.post_deer200_response_intensities import PostDeer200ResponseIntensities +from openapi_client.models.post_deer200_response_net import PostDeer200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostDeer200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Deer calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBuffalo200ResponseScope3 + net: PostDeer200ResponseNet + intensities: PostDeer200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "net", "intensities", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeer200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeer200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBuffalo200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "net": PostDeer200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostDeer200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_net.py new file mode 100644 index 00000000..79d63263 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDeer200ResponseNet(BaseModel): + """ + Net emissions for deer + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeer200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeer200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request.py new file mode 100644 index 00000000..6e7ca665 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_deer_request_deers_inner import PostDeerRequestDeersInner +from openapi_client.models.post_deer_request_vegetation_inner import PostDeerRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequest(BaseModel): + """ + Input data required for the `deer` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + deers: List[PostDeerRequestDeersInner] + vegetation: List[PostDeerRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "rainfallAbove600", "deers", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in deers (list) + _items = [] + if self.deers: + for _item_deers in self.deers: + if _item_deers: + _items.append(_item_deers.to_dict()) + _dict['deers'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "deers": [PostDeerRequestDeersInner.from_dict(_item) for _item in obj["deers"]] if obj.get("deers") is not None else None, + "vegetation": [PostDeerRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner.py new file mode 100644 index 00000000..2d8ab7ca --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_deer_request_deers_inner_classes import PostDeerRequestDeersInnerClasses +from openapi_client.models.post_deer_request_deers_inner_does_fawning import PostDeerRequestDeersInnerDoesFawning +from openapi_client.models.post_deer_request_deers_inner_seasonal_fawning import PostDeerRequestDeersInnerSeasonalFawning +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInner(BaseModel): + """ + PostDeerRequestDeersInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostDeerRequestDeersInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + does_fawning: PostDeerRequestDeersInnerDoesFawning = Field(alias="doesFawning") + seasonal_fawning: PostDeerRequestDeersInnerSeasonalFawning = Field(alias="seasonalFawning") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "herbicide", "herbicideOther", "doesFawning", "seasonalFawning"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of does_fawning + if self.does_fawning: + _dict['doesFawning'] = self.does_fawning.to_dict() + # override the default output from pydantic by calling `to_dict()` of seasonal_fawning + if self.seasonal_fawning: + _dict['seasonalFawning'] = self.seasonal_fawning.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostDeerRequestDeersInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "doesFawning": PostDeerRequestDeersInnerDoesFawning.from_dict(obj["doesFawning"]) if obj.get("doesFawning") is not None else None, + "seasonalFawning": PostDeerRequestDeersInnerSeasonalFawning.from_dict(obj["seasonalFawning"]) if obj.get("seasonalFawning") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes.py new file mode 100644 index 00000000..576c7c46 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes.py @@ -0,0 +1,147 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_deer_request_deers_inner_classes_breeding_does import PostDeerRequestDeersInnerClassesBreedingDoes +from openapi_client.models.post_deer_request_deers_inner_classes_bucks import PostDeerRequestDeersInnerClassesBucks +from openapi_client.models.post_deer_request_deers_inner_classes_fawn import PostDeerRequestDeersInnerClassesFawn +from openapi_client.models.post_deer_request_deers_inner_classes_other_does import PostDeerRequestDeersInnerClassesOtherDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_bucks import PostDeerRequestDeersInnerClassesTradeBucks +from openapi_client.models.post_deer_request_deers_inner_classes_trade_does import PostDeerRequestDeersInnerClassesTradeDoes +from openapi_client.models.post_deer_request_deers_inner_classes_trade_fawn import PostDeerRequestDeersInnerClassesTradeFawn +from openapi_client.models.post_deer_request_deers_inner_classes_trade_other_does import PostDeerRequestDeersInnerClassesTradeOtherDoes +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClasses(BaseModel): + """ + Deer classes of different types + """ # noqa: E501 + bucks: Optional[PostDeerRequestDeersInnerClassesBucks] = None + trade_bucks: Optional[PostDeerRequestDeersInnerClassesTradeBucks] = Field(default=None, alias="tradeBucks") + breeding_does: Optional[PostDeerRequestDeersInnerClassesBreedingDoes] = Field(default=None, alias="breedingDoes") + trade_does: Optional[PostDeerRequestDeersInnerClassesTradeDoes] = Field(default=None, alias="tradeDoes") + other_does: Optional[PostDeerRequestDeersInnerClassesOtherDoes] = Field(default=None, alias="otherDoes") + trade_other_does: Optional[PostDeerRequestDeersInnerClassesTradeOtherDoes] = Field(default=None, alias="tradeOtherDoes") + fawn: Optional[PostDeerRequestDeersInnerClassesFawn] = None + trade_fawn: Optional[PostDeerRequestDeersInnerClassesTradeFawn] = Field(default=None, alias="tradeFawn") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bucks", "tradeBucks", "breedingDoes", "tradeDoes", "otherDoes", "tradeOtherDoes", "fawn", "tradeFawn"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of bucks + if self.bucks: + _dict['bucks'] = self.bucks.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_bucks + if self.trade_bucks: + _dict['tradeBucks'] = self.trade_bucks.to_dict() + # override the default output from pydantic by calling `to_dict()` of breeding_does + if self.breeding_does: + _dict['breedingDoes'] = self.breeding_does.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_does + if self.trade_does: + _dict['tradeDoes'] = self.trade_does.to_dict() + # override the default output from pydantic by calling `to_dict()` of other_does + if self.other_does: + _dict['otherDoes'] = self.other_does.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_other_does + if self.trade_other_does: + _dict['tradeOtherDoes'] = self.trade_other_does.to_dict() + # override the default output from pydantic by calling `to_dict()` of fawn + if self.fawn: + _dict['fawn'] = self.fawn.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_fawn + if self.trade_fawn: + _dict['tradeFawn'] = self.trade_fawn.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bucks": PostDeerRequestDeersInnerClassesBucks.from_dict(obj["bucks"]) if obj.get("bucks") is not None else None, + "tradeBucks": PostDeerRequestDeersInnerClassesTradeBucks.from_dict(obj["tradeBucks"]) if obj.get("tradeBucks") is not None else None, + "breedingDoes": PostDeerRequestDeersInnerClassesBreedingDoes.from_dict(obj["breedingDoes"]) if obj.get("breedingDoes") is not None else None, + "tradeDoes": PostDeerRequestDeersInnerClassesTradeDoes.from_dict(obj["tradeDoes"]) if obj.get("tradeDoes") is not None else None, + "otherDoes": PostDeerRequestDeersInnerClassesOtherDoes.from_dict(obj["otherDoes"]) if obj.get("otherDoes") is not None else None, + "tradeOtherDoes": PostDeerRequestDeersInnerClassesTradeOtherDoes.from_dict(obj["tradeOtherDoes"]) if obj.get("tradeOtherDoes") is not None else None, + "fawn": PostDeerRequestDeersInnerClassesFawn.from_dict(obj["fawn"]) if obj.get("fawn") is not None else None, + "tradeFawn": PostDeerRequestDeersInnerClassesTradeFawn.from_dict(obj["tradeFawn"]) if obj.get("tradeFawn") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_breeding_does.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_breeding_does.py new file mode 100644 index 00000000..be24e6ea --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_breeding_does.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesBreedingDoes(BaseModel): + """ + Breeding does + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesBreedingDoes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesBreedingDoes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_bucks.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_bucks.py new file mode 100644 index 00000000..f27a1d2c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_bucks.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesBucks(BaseModel): + """ + Bucks + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesBucks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesBucks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_fawn.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_fawn.py new file mode 100644 index 00000000..39abbde4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_fawn.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesFawn(BaseModel): + """ + Fawns + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesFawn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesFawn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_other_does.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_other_does.py new file mode 100644 index 00000000..bfbe1246 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_other_does.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesOtherDoes(BaseModel): + """ + Other does + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesOtherDoes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesOtherDoes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_bucks.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_bucks.py new file mode 100644 index 00000000..384c629c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_bucks.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesTradeBucks(BaseModel): + """ + Trade bucks + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeBucks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeBucks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_does.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_does.py new file mode 100644 index 00000000..daa1ae59 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_does.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesTradeDoes(BaseModel): + """ + Trade does + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeDoes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeDoes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_fawn.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_fawn.py new file mode 100644 index 00000000..94e22964 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_fawn.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesTradeFawn(BaseModel): + """ + Trade fawns + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeFawn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeFawn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_other_does.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_other_does.py new file mode 100644 index 00000000..254e5ff1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_classes_trade_other_does.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerClassesTradeOtherDoes(BaseModel): + """ + Trade other does + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeOtherDoes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerClassesTradeOtherDoes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_does_fawning.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_does_fawning.py new file mode 100644 index 00000000..09002da6 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_does_fawning.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerDoesFawning(BaseModel): + """ + Proportion of does fawning in each season, from 0 to 1 + """ # noqa: E501 + spring: Union[StrictFloat, StrictInt] + summer: Union[StrictFloat, StrictInt] + autumn: Union[StrictFloat, StrictInt] + winter: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerDoesFawning from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerDoesFawning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "autumn": obj.get("autumn"), + "winter": obj.get("winter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_seasonal_fawning.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_seasonal_fawning.py new file mode 100644 index 00000000..6a621a9b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_deers_inner_seasonal_fawning.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestDeersInnerSeasonalFawning(BaseModel): + """ + Seasonal fawning rates, from 0 to 1 + """ # noqa: E501 + spring: Union[StrictFloat, StrictInt] + summer: Union[StrictFloat, StrictInt] + autumn: Union[StrictFloat, StrictInt] + winter: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerSeasonalFawning from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestDeersInnerSeasonalFawning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "autumn": obj.get("autumn"), + "winter": obj.get("winter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_deer_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_vegetation_inner.py new file mode 100644 index 00000000..918cd6d9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_deer_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostDeerRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to deer + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + deer_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to deer", alias="deerProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "deerProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostDeerRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostDeerRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "deerProportion": obj.get("deerProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response.py new file mode 100644 index 00000000..fb5ddb38 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_feedlot200_response_intermediate_inner import PostFeedlot200ResponseIntermediateInner +from openapi_client.models.post_feedlot200_response_intermediate_inner_intensities import PostFeedlot200ResponseIntermediateInnerIntensities +from openapi_client.models.post_feedlot200_response_intermediate_inner_net import PostFeedlot200ResponseIntermediateInnerNet +from openapi_client.models.post_feedlot200_response_scope1 import PostFeedlot200ResponseScope1 +from openapi_client.models.post_feedlot200_response_scope3 import PostFeedlot200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200Response(BaseModel): + """ + Emissions calculation output for the `feedlot` calculator + """ # noqa: E501 + scope1: PostFeedlot200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostFeedlot200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostFeedlot200ResponseIntermediateInner] + net: PostFeedlot200ResponseIntermediateInnerNet + intensities: PostFeedlot200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostFeedlot200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostFeedlot200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostFeedlot200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostFeedlot200ResponseIntermediateInnerNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostFeedlot200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner.py new file mode 100644 index 00000000..6ac643d4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_feedlot200_response_intermediate_inner_intensities import PostFeedlot200ResponseIntermediateInnerIntensities +from openapi_client.models.post_feedlot200_response_intermediate_inner_net import PostFeedlot200ResponseIntermediateInnerNet +from openapi_client.models.post_feedlot200_response_scope1 import PostFeedlot200ResponseScope1 +from openapi_client.models.post_feedlot200_response_scope3 import PostFeedlot200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200ResponseIntermediateInner(BaseModel): + """ + PostFeedlot200ResponseIntermediateInner + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostFeedlot200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostFeedlot200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + net: PostFeedlot200ResponseIntermediateInnerNet + intensities: PostFeedlot200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostFeedlot200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostFeedlot200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostFeedlot200ResponseIntermediateInnerNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostFeedlot200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..f8eec11a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostFeedlot200ResponseIntermediateInnerIntensities + """ # noqa: E501 + liveweight_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Amount of meat produced in kg liveweight", alias="liveweightProducedKg") + beef_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef including carbon sequestration, in kg-CO2e/kg liveweight", alias="beefIncludingSequestration") + beef_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="beefExcludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["liveweightProducedKg", "beefIncludingSequestration", "beefExcludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "liveweightProducedKg": obj.get("liveweightProducedKg"), + "beefIncludingSequestration": obj.get("beefIncludingSequestration"), + "beefExcludingSequestration": obj.get("beefExcludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_net.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_net.py new file mode 100644 index 00000000..fb2724f8 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_intermediate_inner_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200ResponseIntermediateInnerNet(BaseModel): + """ + Net emissions for feedlot + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInnerNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseIntermediateInnerNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope1.py new file mode 100644 index 00000000..c94b7b24 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope1.py @@ -0,0 +1,135 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + transport_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from transport, in tonnes-CO2e", alias="transportCO2") + transport_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from transport, in tonnes-CO2e", alias="transportCH4") + transport_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from transport, in tonnes-CO2e", alias="transportN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + manure_direct_n2_o: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management (direct), in tonnes-CO2e", alias="manureDirectN2O") + manure_indirect_n2_o: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management (indirect), in tonnes-CO2e", alias="manureIndirectN2O") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + manure_applied_to_soil_n2_o: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure applied to soil, in tonnes-CO2e", alias="manureAppliedToSoilN2O") + enteric_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from enteric fermentation, in tonnes-CO2e", alias="entericCH4") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "transportCO2", "transportCH4", "transportN2O", "ureaCO2", "limeCO2", "atmosphericDepositionN2O", "manureDirectN2O", "manureIndirectN2O", "manureManagementCH4", "manureAppliedToSoilN2O", "entericCH4", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "transportCO2": obj.get("transportCO2"), + "transportCH4": obj.get("transportCH4"), + "transportN2O": obj.get("transportN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "manureDirectN2O": obj.get("manureDirectN2O"), + "manureIndirectN2O": obj.get("manureIndirectN2O"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "manureAppliedToSoilN2O": obj.get("manureAppliedToSoilN2O"), + "entericCH4": obj.get("entericCH4"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope3.py new file mode 100644 index 00000000..56c44797 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot200_response_scope3.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlot200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from feed, in tonnes-CO2e") + purchase_livestock: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased livestock, in tonnes-CO2e", alias="purchaseLivestock") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "herbicide", "electricity", "fuel", "lime", "feed", "purchaseLivestock", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlot200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "feed": obj.get("feed"), + "purchaseLivestock": obj.get("purchaseLivestock"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request.py new file mode 100644 index 00000000..48d803c0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request.py @@ -0,0 +1,128 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_feedlot_request_feedlots_inner import PostFeedlotRequestFeedlotsInner +from openapi_client.models.post_feedlot_request_vegetation_inner import PostFeedlotRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequest(BaseModel): + """ + Input data required for the `feedlot` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + feedlots: List[PostFeedlotRequestFeedlotsInner] + vegetation: List[PostFeedlotRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "feedlots", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in feedlots (list) + _items = [] + if self.feedlots: + for _item_feedlots in self.feedlots: + if _item_feedlots: + _items.append(_item_feedlots.to_dict()) + _dict['feedlots'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "feedlots": [PostFeedlotRequestFeedlotsInner.from_dict(_item) for _item in obj["feedlots"]] if obj.get("feedlots") is not None else None, + "vegetation": [PostFeedlotRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner.py new file mode 100644 index 00000000..82aa5423 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner.py @@ -0,0 +1,183 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner import PostFeedlotRequestFeedlotsInnerGroupsInner +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases import PostFeedlotRequestFeedlotsInnerPurchases +from openapi_client.models.post_feedlot_request_feedlots_inner_sales import PostFeedlotRequestFeedlotsInnerSales +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInner(BaseModel): + """ + All fields needed to describe the activity of a single feedlot enterprise + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for the feedlot enterprise") + system: StrictStr = Field(description="Type of feedlot/production system") + groups: List[PostFeedlotRequestFeedlotsInnerGroupsInner] + fertiliser: PostBeefRequestBeefInnerFertiliser + purchases: PostFeedlotRequestFeedlotsInnerPurchases + sales: PostFeedlotRequestFeedlotsInnerSales + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + cottonseed_feed: Union[StrictFloat, StrictInt] = Field(description="Cotton seed purchased for cattle feed in tonnes", alias="cottonseedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + distance_cattle_transported: Union[StrictFloat, StrictInt] = Field(description="Distance cattle are transported to farm, in km (kilometres)", alias="distanceCattleTransported") + truck_type: StrictStr = Field(description="Type of truck used for cattle transport", alias="truckType") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "system", "groups", "fertiliser", "purchases", "sales", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "cottonseedFeed", "herbicide", "herbicideOther", "distanceCattleTransported", "truckType", "limestone", "limestoneFraction"] + + @field_validator('system') + def system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Drylot', 'Solid Storage', 'Composting', 'Uncovered anaerobic lagoon']): + raise ValueError("must be one of enum values ('Drylot', 'Solid Storage', 'Composting', 'Uncovered anaerobic lagoon')") + return value + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + @field_validator('truck_type') + def truck_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['4 Deck Trailer', '6 Deck Trailer', 'B-Double']): + raise ValueError("must be one of enum values ('4 Deck Trailer', '6 Deck Trailer', 'B-Double')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in groups (list) + _items = [] + if self.groups: + for _item_groups in self.groups: + if _item_groups: + _items.append(_item_groups.to_dict()) + _dict['groups'] = _items + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchases + if self.purchases: + _dict['purchases'] = self.purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of sales + if self.sales: + _dict['sales'] = self.sales.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "system": obj.get("system"), + "groups": [PostFeedlotRequestFeedlotsInnerGroupsInner.from_dict(_item) for _item in obj["groups"]] if obj.get("groups") is not None else None, + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "purchases": PostFeedlotRequestFeedlotsInnerPurchases.from_dict(obj["purchases"]) if obj.get("purchases") is not None else None, + "sales": PostFeedlotRequestFeedlotsInnerSales.from_dict(obj["sales"]) if obj.get("sales") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "cottonseedFeed": obj.get("cottonseedFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "distanceCattleTransported": obj.get("distanceCattleTransported"), + "truckType": obj.get("truckType"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner.py new file mode 100644 index 00000000..64121073 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_feedlot_request_feedlots_inner_groups_inner_stays_inner import PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerGroupsInner(BaseModel): + """ + PostFeedlotRequestFeedlotsInnerGroupsInner + """ # noqa: E501 + stays: List[PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["stays"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in stays (list) + _items = [] + if self.stays: + for _item_stays in self.stays: + if _item_stays: + _items.append(_item_stays.to_dict()) + _dict['stays'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "stays": [PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner.from_dict(_item) for _item in obj["stays"]] if obj.get("stays") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner_stays_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner_stays_inner.py new file mode 100644 index 00000000..e080e97b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_groups_inner_stays_inner.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner(BaseModel): + """ + A class of cattle with a specific feedlot stay duration + """ # noqa: E501 + livestock: Union[StrictFloat, StrictInt] = Field(description="Number of animals (head)") + stay_average_duration: Union[StrictFloat, StrictInt] = Field(description="Average stay length in feedlot, in days", alias="stayAverageDuration") + liveweight: Union[StrictFloat, StrictInt] = Field(description="Average liveweight of animals in kg/head (kilogram per head)") + dry_matter_digestibility: Union[StrictFloat, StrictInt] = Field(description="Percent dry matter digestibility of the feed eaten, from 0 to 100", alias="dryMatterDigestibility") + crude_protein: Union[StrictFloat, StrictInt] = Field(description="Percent crude protein of the whole diet, from 0 to 100", alias="crudeProtein") + nitrogen_retention: Union[StrictFloat, StrictInt] = Field(description="Percent nitrogen retention of intake, from 0 to 100", alias="nitrogenRetention") + daily_intake: Union[StrictFloat, StrictInt] = Field(description="Daily intake of dry matter in kilograms per head per day", alias="dailyIntake") + ndf: Union[StrictFloat, StrictInt] = Field(description="Percent Neutral detergent fibre (NDF) of intake, from 0 to 100") + ether_extract: Union[StrictFloat, StrictInt] = Field(description="Percent ether extract of intake, from 0 to 100", alias="etherExtract") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["livestock", "stayAverageDuration", "liveweight", "dryMatterDigestibility", "crudeProtein", "nitrogenRetention", "dailyIntake", "ndf", "etherExtract"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerGroupsInnerStaysInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "livestock": obj.get("livestock"), + "stayAverageDuration": obj.get("stayAverageDuration"), + "liveweight": obj.get("liveweight"), + "dryMatterDigestibility": obj.get("dryMatterDigestibility"), + "crudeProtein": obj.get("crudeProtein"), + "nitrogenRetention": obj.get("nitrogenRetention"), + "dailyIntake": obj.get("dailyIntake"), + "ndf": obj.get("ndf"), + "etherExtract": obj.get("etherExtract") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases.py new file mode 100644 index 00000000..6deac44f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases.py @@ -0,0 +1,244 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerPurchases(BaseModel): + """ + Note: passing a single `FeedlotPurchase` for each class is now deprecated, please pass an array (`FeedlotPurchases[]`) instead + """ # noqa: E501 + bulls_gt1: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for bulls whose age is greater than 1 year old", alias="bullsGt1") + bulls_gt1_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded bulls whose age is greater than 1 year old", alias="bullsGt1Traded") + steers_lt1: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Steers whose age is less than 1 year old", alias="steersLt1") + steers_lt1_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Steers whose age is less than 1 year old", alias="steersLt1Traded") + steers1_to2: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Steers whose age is between 1 and 2 years old", alias="steers1To2") + steers1_to2_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Steers whose age is between 1 and 2 years old", alias="steers1To2Traded") + steers_gt2: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Steers whose age is greater than 2 years old", alias="steersGt2") + steers_gt2_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Steers whose age is greater than 2 years old", alias="steersGt2Traded") + cows_gt2: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Cows whose age is greater than 2 years old", alias="cowsGt2") + cows_gt2_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Cows whose age is greater than 2 years old", alias="cowsGt2Traded") + heifers_lt1: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Heifers whose age is less than 1 year old", alias="heifersLt1") + heifers_lt1_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Heifers whose age is less than 1 year old", alias="heifersLt1Traded") + heifers1_to2: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Heifers whose age is between 1 and 2 years old", alias="heifers1To2") + heifers1_to2_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Heifers whose age is between 1 and 2 years old", alias="heifers1To2Traded") + heifers_gt2: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for Heifers whose age is greater than 2 years old", alias="heifersGt2") + heifers_gt2_traded: Optional[List[PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner]] = Field(default=None, description="Livestock purchases for traded Heifers whose age is greater than 2 years old", alias="heifersGt2Traded") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bullsGt1", "bullsGt1Traded", "steersLt1", "steersLt1Traded", "steers1To2", "steers1To2Traded", "steersGt2", "steersGt2Traded", "cowsGt2", "cowsGt2Traded", "heifersLt1", "heifersLt1Traded", "heifers1To2", "heifers1To2Traded", "heifersGt2", "heifersGt2Traded"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerPurchases from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in bulls_gt1 (list) + _items = [] + if self.bulls_gt1: + for _item_bulls_gt1 in self.bulls_gt1: + if _item_bulls_gt1: + _items.append(_item_bulls_gt1.to_dict()) + _dict['bullsGt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bulls_gt1_traded (list) + _items = [] + if self.bulls_gt1_traded: + for _item_bulls_gt1_traded in self.bulls_gt1_traded: + if _item_bulls_gt1_traded: + _items.append(_item_bulls_gt1_traded.to_dict()) + _dict['bullsGt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_lt1 (list) + _items = [] + if self.steers_lt1: + for _item_steers_lt1 in self.steers_lt1: + if _item_steers_lt1: + _items.append(_item_steers_lt1.to_dict()) + _dict['steersLt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_lt1_traded (list) + _items = [] + if self.steers_lt1_traded: + for _item_steers_lt1_traded in self.steers_lt1_traded: + if _item_steers_lt1_traded: + _items.append(_item_steers_lt1_traded.to_dict()) + _dict['steersLt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers1_to2 (list) + _items = [] + if self.steers1_to2: + for _item_steers1_to2 in self.steers1_to2: + if _item_steers1_to2: + _items.append(_item_steers1_to2.to_dict()) + _dict['steers1To2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers1_to2_traded (list) + _items = [] + if self.steers1_to2_traded: + for _item_steers1_to2_traded in self.steers1_to2_traded: + if _item_steers1_to2_traded: + _items.append(_item_steers1_to2_traded.to_dict()) + _dict['steers1To2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_gt2 (list) + _items = [] + if self.steers_gt2: + for _item_steers_gt2 in self.steers_gt2: + if _item_steers_gt2: + _items.append(_item_steers_gt2.to_dict()) + _dict['steersGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_gt2_traded (list) + _items = [] + if self.steers_gt2_traded: + for _item_steers_gt2_traded in self.steers_gt2_traded: + if _item_steers_gt2_traded: + _items.append(_item_steers_gt2_traded.to_dict()) + _dict['steersGt2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in cows_gt2 (list) + _items = [] + if self.cows_gt2: + for _item_cows_gt2 in self.cows_gt2: + if _item_cows_gt2: + _items.append(_item_cows_gt2.to_dict()) + _dict['cowsGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in cows_gt2_traded (list) + _items = [] + if self.cows_gt2_traded: + for _item_cows_gt2_traded in self.cows_gt2_traded: + if _item_cows_gt2_traded: + _items.append(_item_cows_gt2_traded.to_dict()) + _dict['cowsGt2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_lt1 (list) + _items = [] + if self.heifers_lt1: + for _item_heifers_lt1 in self.heifers_lt1: + if _item_heifers_lt1: + _items.append(_item_heifers_lt1.to_dict()) + _dict['heifersLt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_lt1_traded (list) + _items = [] + if self.heifers_lt1_traded: + for _item_heifers_lt1_traded in self.heifers_lt1_traded: + if _item_heifers_lt1_traded: + _items.append(_item_heifers_lt1_traded.to_dict()) + _dict['heifersLt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers1_to2 (list) + _items = [] + if self.heifers1_to2: + for _item_heifers1_to2 in self.heifers1_to2: + if _item_heifers1_to2: + _items.append(_item_heifers1_to2.to_dict()) + _dict['heifers1To2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers1_to2_traded (list) + _items = [] + if self.heifers1_to2_traded: + for _item_heifers1_to2_traded in self.heifers1_to2_traded: + if _item_heifers1_to2_traded: + _items.append(_item_heifers1_to2_traded.to_dict()) + _dict['heifers1To2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_gt2 (list) + _items = [] + if self.heifers_gt2: + for _item_heifers_gt2 in self.heifers_gt2: + if _item_heifers_gt2: + _items.append(_item_heifers_gt2.to_dict()) + _dict['heifersGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_gt2_traded (list) + _items = [] + if self.heifers_gt2_traded: + for _item_heifers_gt2_traded in self.heifers_gt2_traded: + if _item_heifers_gt2_traded: + _items.append(_item_heifers_gt2_traded.to_dict()) + _dict['heifersGt2Traded'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerPurchases from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bullsGt1": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["bullsGt1"]] if obj.get("bullsGt1") is not None else None, + "bullsGt1Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["bullsGt1Traded"]] if obj.get("bullsGt1Traded") is not None else None, + "steersLt1": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steersLt1"]] if obj.get("steersLt1") is not None else None, + "steersLt1Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steersLt1Traded"]] if obj.get("steersLt1Traded") is not None else None, + "steers1To2": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steers1To2"]] if obj.get("steers1To2") is not None else None, + "steers1To2Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steers1To2Traded"]] if obj.get("steers1To2Traded") is not None else None, + "steersGt2": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steersGt2"]] if obj.get("steersGt2") is not None else None, + "steersGt2Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["steersGt2Traded"]] if obj.get("steersGt2Traded") is not None else None, + "cowsGt2": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["cowsGt2"]] if obj.get("cowsGt2") is not None else None, + "cowsGt2Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["cowsGt2Traded"]] if obj.get("cowsGt2Traded") is not None else None, + "heifersLt1": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifersLt1"]] if obj.get("heifersLt1") is not None else None, + "heifersLt1Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifersLt1Traded"]] if obj.get("heifersLt1Traded") is not None else None, + "heifers1To2": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifers1To2"]] if obj.get("heifers1To2") is not None else None, + "heifers1To2Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifers1To2Traded"]] if obj.get("heifers1To2Traded") is not None else None, + "heifersGt2": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifersGt2"]] if obj.get("heifersGt2") is not None else None, + "heifersGt2Traded": [PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner.from_dict(_item) for _item in obj["heifersGt2Traded"]] if obj.get("heifersGt2Traded") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner.py new file mode 100644 index 00000000..a9a5af82 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_purchases_bulls_gt1_inner.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner(BaseModel): + """ + PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + purchase_source: StrictStr = Field(description="Source location of trading cattle purchases", alias="purchaseSource") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight", "purchaseSource"] + + @field_validator('purchase_source') + def purchase_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['NT', 'nth QLD', 'sth/central QLD', 'nth NSW', 'sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS']): + raise ValueError("must be one of enum values ('NT', 'nth QLD', 'sth/central QLD', 'nth NSW', 'sth NSW/VIC/sth SA', 'NSW/SA pastoral zone', 'sw WA', 'WA pastoral', 'TAS')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerPurchasesBullsGt1Inner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight"), + "purchaseSource": obj.get("purchaseSource") if obj.get("purchaseSource") is not None else 'sth NSW/VIC/sth SA' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales.py new file mode 100644 index 00000000..17886fd7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales.py @@ -0,0 +1,244 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerSales(BaseModel): + """ + Note: passing a single `FeedlotSale` for each class is now deprecated, please pass an array (`FeedlotSales[]`) instead + """ # noqa: E501 + bulls_gt1: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for bulls whose age is greater than 1 year old", alias="bullsGt1") + bulls_gt1_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded bulls whose age is greater than 1 year old", alias="bullsGt1Traded") + steers_lt1: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Steers whose age is less than 1 year old", alias="steersLt1") + steers_lt1_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Steers whose age is less than 1 year old", alias="steersLt1Traded") + steers1_to2: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Steers whose age is between 1 and 2 years old", alias="steers1To2") + steers1_to2_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Steers whose age is between 1 and 2 years old", alias="steers1To2Traded") + steers_gt2: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Steers whose age is greater than 2 years old", alias="steersGt2") + steers_gt2_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Steers whose age is greater than 2 years old", alias="steersGt2Traded") + cows_gt2: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Cows whose age is greater than 2 years old", alias="cowsGt2") + cows_gt2_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Cows whose age is greater than 2 years old", alias="cowsGt2Traded") + heifers_lt1: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Heifers whose age is less than 1 year old", alias="heifersLt1") + heifers_lt1_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Heifers whose age is less than 1 year old", alias="heifersLt1Traded") + heifers1_to2: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Heifers whose age is between 1 and 2 years old", alias="heifers1To2") + heifers1_to2_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Heifers whose age is between 1 and 2 years old", alias="heifers1To2Traded") + heifers_gt2: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for Heifers whose age is greater than 2 years old", alias="heifersGt2") + heifers_gt2_traded: List[PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner] = Field(description="Livestock sales for traded Heifers whose age is greater than 2 years old", alias="heifersGt2Traded") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bullsGt1", "bullsGt1Traded", "steersLt1", "steersLt1Traded", "steers1To2", "steers1To2Traded", "steersGt2", "steersGt2Traded", "cowsGt2", "cowsGt2Traded", "heifersLt1", "heifersLt1Traded", "heifers1To2", "heifers1To2Traded", "heifersGt2", "heifersGt2Traded"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerSales from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in bulls_gt1 (list) + _items = [] + if self.bulls_gt1: + for _item_bulls_gt1 in self.bulls_gt1: + if _item_bulls_gt1: + _items.append(_item_bulls_gt1.to_dict()) + _dict['bullsGt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bulls_gt1_traded (list) + _items = [] + if self.bulls_gt1_traded: + for _item_bulls_gt1_traded in self.bulls_gt1_traded: + if _item_bulls_gt1_traded: + _items.append(_item_bulls_gt1_traded.to_dict()) + _dict['bullsGt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_lt1 (list) + _items = [] + if self.steers_lt1: + for _item_steers_lt1 in self.steers_lt1: + if _item_steers_lt1: + _items.append(_item_steers_lt1.to_dict()) + _dict['steersLt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_lt1_traded (list) + _items = [] + if self.steers_lt1_traded: + for _item_steers_lt1_traded in self.steers_lt1_traded: + if _item_steers_lt1_traded: + _items.append(_item_steers_lt1_traded.to_dict()) + _dict['steersLt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers1_to2 (list) + _items = [] + if self.steers1_to2: + for _item_steers1_to2 in self.steers1_to2: + if _item_steers1_to2: + _items.append(_item_steers1_to2.to_dict()) + _dict['steers1To2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers1_to2_traded (list) + _items = [] + if self.steers1_to2_traded: + for _item_steers1_to2_traded in self.steers1_to2_traded: + if _item_steers1_to2_traded: + _items.append(_item_steers1_to2_traded.to_dict()) + _dict['steers1To2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_gt2 (list) + _items = [] + if self.steers_gt2: + for _item_steers_gt2 in self.steers_gt2: + if _item_steers_gt2: + _items.append(_item_steers_gt2.to_dict()) + _dict['steersGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in steers_gt2_traded (list) + _items = [] + if self.steers_gt2_traded: + for _item_steers_gt2_traded in self.steers_gt2_traded: + if _item_steers_gt2_traded: + _items.append(_item_steers_gt2_traded.to_dict()) + _dict['steersGt2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in cows_gt2 (list) + _items = [] + if self.cows_gt2: + for _item_cows_gt2 in self.cows_gt2: + if _item_cows_gt2: + _items.append(_item_cows_gt2.to_dict()) + _dict['cowsGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in cows_gt2_traded (list) + _items = [] + if self.cows_gt2_traded: + for _item_cows_gt2_traded in self.cows_gt2_traded: + if _item_cows_gt2_traded: + _items.append(_item_cows_gt2_traded.to_dict()) + _dict['cowsGt2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_lt1 (list) + _items = [] + if self.heifers_lt1: + for _item_heifers_lt1 in self.heifers_lt1: + if _item_heifers_lt1: + _items.append(_item_heifers_lt1.to_dict()) + _dict['heifersLt1'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_lt1_traded (list) + _items = [] + if self.heifers_lt1_traded: + for _item_heifers_lt1_traded in self.heifers_lt1_traded: + if _item_heifers_lt1_traded: + _items.append(_item_heifers_lt1_traded.to_dict()) + _dict['heifersLt1Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers1_to2 (list) + _items = [] + if self.heifers1_to2: + for _item_heifers1_to2 in self.heifers1_to2: + if _item_heifers1_to2: + _items.append(_item_heifers1_to2.to_dict()) + _dict['heifers1To2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers1_to2_traded (list) + _items = [] + if self.heifers1_to2_traded: + for _item_heifers1_to2_traded in self.heifers1_to2_traded: + if _item_heifers1_to2_traded: + _items.append(_item_heifers1_to2_traded.to_dict()) + _dict['heifers1To2Traded'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_gt2 (list) + _items = [] + if self.heifers_gt2: + for _item_heifers_gt2 in self.heifers_gt2: + if _item_heifers_gt2: + _items.append(_item_heifers_gt2.to_dict()) + _dict['heifersGt2'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in heifers_gt2_traded (list) + _items = [] + if self.heifers_gt2_traded: + for _item_heifers_gt2_traded in self.heifers_gt2_traded: + if _item_heifers_gt2_traded: + _items.append(_item_heifers_gt2_traded.to_dict()) + _dict['heifersGt2Traded'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerSales from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bullsGt1": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["bullsGt1"]] if obj.get("bullsGt1") is not None else None, + "bullsGt1Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["bullsGt1Traded"]] if obj.get("bullsGt1Traded") is not None else None, + "steersLt1": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steersLt1"]] if obj.get("steersLt1") is not None else None, + "steersLt1Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steersLt1Traded"]] if obj.get("steersLt1Traded") is not None else None, + "steers1To2": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steers1To2"]] if obj.get("steers1To2") is not None else None, + "steers1To2Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steers1To2Traded"]] if obj.get("steers1To2Traded") is not None else None, + "steersGt2": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steersGt2"]] if obj.get("steersGt2") is not None else None, + "steersGt2Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["steersGt2Traded"]] if obj.get("steersGt2Traded") is not None else None, + "cowsGt2": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["cowsGt2"]] if obj.get("cowsGt2") is not None else None, + "cowsGt2Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["cowsGt2Traded"]] if obj.get("cowsGt2Traded") is not None else None, + "heifersLt1": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifersLt1"]] if obj.get("heifersLt1") is not None else None, + "heifersLt1Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifersLt1Traded"]] if obj.get("heifersLt1Traded") is not None else None, + "heifers1To2": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifers1To2"]] if obj.get("heifers1To2") is not None else None, + "heifers1To2Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifers1To2Traded"]] if obj.get("heifers1To2Traded") is not None else None, + "heifersGt2": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifersGt2"]] if obj.get("heifersGt2") is not None else None, + "heifersGt2Traded": [PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(_item) for _item in obj["heifersGt2Traded"]] if obj.get("heifersGt2Traded") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner.py new file mode 100644 index 00000000..ee1438c4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner(BaseModel): + """ + PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "saleWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "saleWeight": obj.get("saleWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_vegetation_inner.py new file mode 100644 index 00000000..d17cb658 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_feedlot_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostFeedlotRequestVegetationInner(BaseModel): + """ + PostFeedlotRequestVegetationInner + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + feedlot_proportion: List[Union[StrictFloat, StrictInt]] = Field(alias="feedlotProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "feedlotProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostFeedlotRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostFeedlotRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "feedlotProportion": obj.get("feedlotProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response.py new file mode 100644 index 00000000..d332c27e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_goat200_response_intensities import PostGoat200ResponseIntensities +from openapi_client.models.post_goat200_response_intermediate_inner import PostGoat200ResponseIntermediateInner +from openapi_client.models.post_goat200_response_net import PostGoat200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostGoat200Response(BaseModel): + """ + Emissions calculation output for the `goat` calculator + """ # noqa: E501 + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + net: PostGoat200ResponseNet + intensities: PostGoat200ResponseIntensities + intermediate: List[PostGoat200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoat200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoat200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostGoat200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostGoat200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "intermediate": [PostGoat200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intensities.py new file mode 100644 index 00000000..0bd59999 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intensities.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostGoat200ResponseIntensities(BaseModel): + """ + PostGoat200ResponseIntensities + """ # noqa: E501 + amount_meat_produced: Union[StrictFloat, StrictInt] = Field(description="Amount of goat meat produced in kg liveweight", alias="amountMeatProduced") + amount_wool_produced: Union[StrictFloat, StrictInt] = Field(description="Amount of wool produced in kg greasy", alias="amountWoolProduced") + goat_meat_breeding_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Goat meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight", alias="goatMeatBreedingIncludingSequestration") + goat_meat_breeding_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Goat meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="goatMeatBreedingExcludingSequestration") + wool_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production including carbon sequestration, in kg-CO2e/kg greasy", alias="woolIncludingSequestration") + wool_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production excluding carbon sequestration, in kg-CO2e/kg greasy", alias="woolExcludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["amountMeatProduced", "amountWoolProduced", "goatMeatBreedingIncludingSequestration", "goatMeatBreedingExcludingSequestration", "woolIncludingSequestration", "woolExcludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoat200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoat200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "amountMeatProduced": obj.get("amountMeatProduced"), + "amountWoolProduced": obj.get("amountWoolProduced"), + "goatMeatBreedingIncludingSequestration": obj.get("goatMeatBreedingIncludingSequestration"), + "goatMeatBreedingExcludingSequestration": obj.get("goatMeatBreedingExcludingSequestration"), + "woolIncludingSequestration": obj.get("woolIncludingSequestration"), + "woolExcludingSequestration": obj.get("woolExcludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intermediate_inner.py new file mode 100644 index 00000000..f7c20c9b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_goat200_response_intensities import PostGoat200ResponseIntensities +from openapi_client.models.post_goat200_response_net import PostGoat200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostGoat200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Goat calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + net: PostGoat200ResponseNet + intensities: PostGoat200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "net", "intensities", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoat200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoat200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "net": PostGoat200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostGoat200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_net.py new file mode 100644 index 00000000..af2eeb64 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostGoat200ResponseNet(BaseModel): + """ + Net emissions for goat + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoat200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoat200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request.py new file mode 100644 index 00000000..ee61a08a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request.py @@ -0,0 +1,130 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_goat_request_goats_inner import PostGoatRequestGoatsInner +from openapi_client.models.post_goat_request_vegetation_inner import PostGoatRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequest(BaseModel): + """ + Input data required for the `goat` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + goats: List[PostGoatRequestGoatsInner] + vegetation: List[PostGoatRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "rainfallAbove600", "goats", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in goats (list) + _items = [] + if self.goats: + for _item_goats in self.goats: + if _item_goats: + _items.append(_item_goats.to_dict()) + _dict['goats'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "goats": [PostGoatRequestGoatsInner.from_dict(_item) for _item in obj["goats"]] if obj.get("goats") is not None else None, + "vegetation": [PostGoatRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner.py new file mode 100644 index 00000000..d3499107 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner.py @@ -0,0 +1,151 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_beef_request_beef_inner_mineral_supplementation import PostBeefRequestBeefInnerMineralSupplementation +from openapi_client.models.post_goat_request_goats_inner_classes import PostGoatRequestGoatsInnerClasses +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInner(BaseModel): + """ + PostGoatRequestGoatsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostGoatRequestGoatsInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + mineral_supplementation: PostBeefRequestBeefInnerMineralSupplementation = Field(alias="mineralSupplementation") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "mineralSupplementation", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "herbicide", "herbicideOther"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of mineral_supplementation + if self.mineral_supplementation: + _dict['mineralSupplementation'] = self.mineral_supplementation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostGoatRequestGoatsInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "mineralSupplementation": PostBeefRequestBeefInnerMineralSupplementation.from_dict(obj["mineralSupplementation"]) if obj.get("mineralSupplementation") is not None else None, + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes.py new file mode 100644 index 00000000..162cb773 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes.py @@ -0,0 +1,177 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_goat_request_goats_inner_classes_breeding_does_nannies import PostGoatRequestGoatsInnerClassesBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_bucks_billy import PostGoatRequestGoatsInnerClassesBucksBilly +from openapi_client.models.post_goat_request_goats_inner_classes_kids import PostGoatRequestGoatsInnerClassesKids +from openapi_client.models.post_goat_request_goats_inner_classes_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_other_does_culled_females import PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_bucks import PostGoatRequestGoatsInnerClassesTradeBucks +from openapi_client.models.post_goat_request_goats_inner_classes_trade_does import PostGoatRequestGoatsInnerClassesTradeDoes +from openapi_client.models.post_goat_request_goats_inner_classes_trade_kids import PostGoatRequestGoatsInnerClassesTradeKids +from openapi_client.models.post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies import PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies +from openapi_client.models.post_goat_request_goats_inner_classes_trade_other_does_culled_females import PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales +from openapi_client.models.post_goat_request_goats_inner_classes_trade_wethers import PostGoatRequestGoatsInnerClassesTradeWethers +from openapi_client.models.post_goat_request_goats_inner_classes_wethers import PostGoatRequestGoatsInnerClassesWethers +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClasses(BaseModel): + """ + Goat classes of different types + """ # noqa: E501 + bucks_billy: Optional[PostGoatRequestGoatsInnerClassesBucksBilly] = Field(default=None, alias="bucksBilly") + trade_bucks: Optional[PostGoatRequestGoatsInnerClassesTradeBucks] = Field(default=None, alias="tradeBucks") + wethers: Optional[PostGoatRequestGoatsInnerClassesWethers] = None + trade_wethers: Optional[PostGoatRequestGoatsInnerClassesTradeWethers] = Field(default=None, alias="tradeWethers") + maiden_breeding_does_nannies: Optional[PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies] = Field(default=None, alias="maidenBreedingDoesNannies") + trade_maiden_breeding_does_nannies: Optional[PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies] = Field(default=None, alias="tradeMaidenBreedingDoesNannies") + breeding_does_nannies: Optional[PostGoatRequestGoatsInnerClassesBreedingDoesNannies] = Field(default=None, alias="breedingDoesNannies") + trade_breeding_does_nannies: Optional[PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies] = Field(default=None, alias="tradeBreedingDoesNannies") + other_does_culled_females: Optional[PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales] = Field(default=None, alias="otherDoesCulledFemales") + trade_other_does_culled_females: Optional[PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales] = Field(default=None, alias="tradeOtherDoesCulledFemales") + kids: Optional[PostGoatRequestGoatsInnerClassesKids] = None + trade_kids: Optional[PostGoatRequestGoatsInnerClassesTradeKids] = Field(default=None, alias="tradeKids") + trade_does: Optional[PostGoatRequestGoatsInnerClassesTradeDoes] = Field(default=None, alias="tradeDoes") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["bucksBilly", "tradeBucks", "wethers", "tradeWethers", "maidenBreedingDoesNannies", "tradeMaidenBreedingDoesNannies", "breedingDoesNannies", "tradeBreedingDoesNannies", "otherDoesCulledFemales", "tradeOtherDoesCulledFemales", "kids", "tradeKids", "tradeDoes"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of bucks_billy + if self.bucks_billy: + _dict['bucksBilly'] = self.bucks_billy.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_bucks + if self.trade_bucks: + _dict['tradeBucks'] = self.trade_bucks.to_dict() + # override the default output from pydantic by calling `to_dict()` of wethers + if self.wethers: + _dict['wethers'] = self.wethers.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_wethers + if self.trade_wethers: + _dict['tradeWethers'] = self.trade_wethers.to_dict() + # override the default output from pydantic by calling `to_dict()` of maiden_breeding_does_nannies + if self.maiden_breeding_does_nannies: + _dict['maidenBreedingDoesNannies'] = self.maiden_breeding_does_nannies.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_maiden_breeding_does_nannies + if self.trade_maiden_breeding_does_nannies: + _dict['tradeMaidenBreedingDoesNannies'] = self.trade_maiden_breeding_does_nannies.to_dict() + # override the default output from pydantic by calling `to_dict()` of breeding_does_nannies + if self.breeding_does_nannies: + _dict['breedingDoesNannies'] = self.breeding_does_nannies.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_breeding_does_nannies + if self.trade_breeding_does_nannies: + _dict['tradeBreedingDoesNannies'] = self.trade_breeding_does_nannies.to_dict() + # override the default output from pydantic by calling `to_dict()` of other_does_culled_females + if self.other_does_culled_females: + _dict['otherDoesCulledFemales'] = self.other_does_culled_females.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_other_does_culled_females + if self.trade_other_does_culled_females: + _dict['tradeOtherDoesCulledFemales'] = self.trade_other_does_culled_females.to_dict() + # override the default output from pydantic by calling `to_dict()` of kids + if self.kids: + _dict['kids'] = self.kids.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_kids + if self.trade_kids: + _dict['tradeKids'] = self.trade_kids.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_does + if self.trade_does: + _dict['tradeDoes'] = self.trade_does.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "bucksBilly": PostGoatRequestGoatsInnerClassesBucksBilly.from_dict(obj["bucksBilly"]) if obj.get("bucksBilly") is not None else None, + "tradeBucks": PostGoatRequestGoatsInnerClassesTradeBucks.from_dict(obj["tradeBucks"]) if obj.get("tradeBucks") is not None else None, + "wethers": PostGoatRequestGoatsInnerClassesWethers.from_dict(obj["wethers"]) if obj.get("wethers") is not None else None, + "tradeWethers": PostGoatRequestGoatsInnerClassesTradeWethers.from_dict(obj["tradeWethers"]) if obj.get("tradeWethers") is not None else None, + "maidenBreedingDoesNannies": PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies.from_dict(obj["maidenBreedingDoesNannies"]) if obj.get("maidenBreedingDoesNannies") is not None else None, + "tradeMaidenBreedingDoesNannies": PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies.from_dict(obj["tradeMaidenBreedingDoesNannies"]) if obj.get("tradeMaidenBreedingDoesNannies") is not None else None, + "breedingDoesNannies": PostGoatRequestGoatsInnerClassesBreedingDoesNannies.from_dict(obj["breedingDoesNannies"]) if obj.get("breedingDoesNannies") is not None else None, + "tradeBreedingDoesNannies": PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies.from_dict(obj["tradeBreedingDoesNannies"]) if obj.get("tradeBreedingDoesNannies") is not None else None, + "otherDoesCulledFemales": PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales.from_dict(obj["otherDoesCulledFemales"]) if obj.get("otherDoesCulledFemales") is not None else None, + "tradeOtherDoesCulledFemales": PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales.from_dict(obj["tradeOtherDoesCulledFemales"]) if obj.get("tradeOtherDoesCulledFemales") is not None else None, + "kids": PostGoatRequestGoatsInnerClassesKids.from_dict(obj["kids"]) if obj.get("kids") is not None else None, + "tradeKids": PostGoatRequestGoatsInnerClassesTradeKids.from_dict(obj["tradeKids"]) if obj.get("tradeKids") is not None else None, + "tradeDoes": PostGoatRequestGoatsInnerClassesTradeDoes.from_dict(obj["tradeDoes"]) if obj.get("tradeDoes") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_breeding_does_nannies.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_breeding_does_nannies.py new file mode 100644 index 00000000..13dc0bed --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_breeding_does_nannies.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesBreedingDoesNannies(BaseModel): + """ + breeding does/nannies + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesBreedingDoesNannies from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesBreedingDoesNannies from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_bucks_billy.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_bucks_billy.py new file mode 100644 index 00000000..69ddd5ed --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_bucks_billy.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesBucksBilly(BaseModel): + """ + Bucks / Billy + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesBucksBilly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesBucksBilly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_kids.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_kids.py new file mode 100644 index 00000000..ecfc3724 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_kids.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesKids(BaseModel): + """ + kids + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesKids from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesKids from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_maiden_breeding_does_nannies.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_maiden_breeding_does_nannies.py new file mode 100644 index 00000000..5daf9ba6 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_maiden_breeding_does_nannies.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies(BaseModel): + """ + maiden breeding does/nannies + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesMaidenBreedingDoesNannies from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_other_does_culled_females.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_other_does_culled_females.py new file mode 100644 index 00000000..25836557 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_other_does_culled_females.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales(BaseModel): + """ + other does/culled females + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesOtherDoesCulledFemales from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_breeding_does_nannies.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_breeding_does_nannies.py new file mode 100644 index 00000000..43972309 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_breeding_does_nannies.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies(BaseModel): + """ + trade breeding does/nannies + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeBreedingDoesNannies from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_bucks.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_bucks.py new file mode 100644 index 00000000..9e3b2867 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_bucks.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeBucks(BaseModel): + """ + Trade Bucks / Billy + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeBucks from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeBucks from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_does.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_does.py new file mode 100644 index 00000000..436ddf2e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_does.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeDoes(BaseModel): + """ + Trade does. Deprecation note: More specific trade doe classes now available + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeDoes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeDoes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_kids.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_kids.py new file mode 100644 index 00000000..e79deb02 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_kids.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeKids(BaseModel): + """ + trade kids + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeKids from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeKids from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies.py new file mode 100644 index 00000000..5e5bf41b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_maiden_breeding_does_nannies.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies(BaseModel): + """ + trade maiden breeding does/nannies + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeMaidenBreedingDoesNannies from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_other_does_culled_females.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_other_does_culled_females.py new file mode 100644 index 00000000..c9199be7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_other_does_culled_females.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales(BaseModel): + """ + trade other does/culled females + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeOtherDoesCulledFemales from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_wethers.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_wethers.py new file mode 100644 index 00000000..098d67d2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_trade_wethers.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesTradeWethers(BaseModel): + """ + trade wethers + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeWethers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesTradeWethers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_wethers.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_wethers.py new file mode 100644 index 00000000..e70704fa --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_goats_inner_classes_wethers.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_autumn import PostBuffaloRequestBuffalosInnerClassesBullsAutumn +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestGoatsInnerClassesWethers(BaseModel): + """ + wethers + """ # noqa: E501 + autumn: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + winter: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + spring: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + summer: PostBuffaloRequestBuffalosInnerClassesBullsAutumn + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of goat shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "headShorn", "woolShorn", "cleanWoolYield", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesWethers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestGoatsInnerClassesWethers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostBuffaloRequestBuffalosInnerClassesBullsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_goat_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_vegetation_inner.py new file mode 100644 index 00000000..5b0f010f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_goat_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostGoatRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to goat + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + goat_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to goat", alias="goatProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "goatProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGoatRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGoatRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "goatProportion": obj.get("goatProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_grains200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response.py new file mode 100644 index 00000000..3ebd3e10 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response.py @@ -0,0 +1,151 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_grains200_response_intermediate_inner import PostGrains200ResponseIntermediateInner +from openapi_client.models.post_grains200_response_intermediate_inner_intensities_with_sequestration import PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration +from typing import Optional, Set +from typing_extensions import Self + +class PostGrains200Response(BaseModel): + """ + Emissions calculation output for the `grains` calculator + """ # noqa: E501 + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostGrains200ResponseIntermediateInner] + net: PostCotton200ResponseNet + intensities_with_sequestration: List[PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration] = Field(description="Emissions intensity for each crop (in order), in t-CO2e/t crop", alias="intensitiesWithSequestration") + intensities: List[Union[StrictFloat, StrictInt]] = Field(description="Emissions intensity for each crop (in order), in t-CO2e/t crop") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensitiesWithSequestration", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGrains200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities_with_sequestration (list) + _items = [] + if self.intensities_with_sequestration: + for _item_intensities_with_sequestration in self.intensities_with_sequestration: + if _item_intensities_with_sequestration: + _items.append(_item_intensities_with_sequestration.to_dict()) + _dict['intensitiesWithSequestration'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGrains200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostGrains200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostCotton200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensitiesWithSequestration": [PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.from_dict(_item) for _item in obj["intensitiesWithSequestration"]] if obj.get("intensitiesWithSequestration") is not None else None, + "intensities": obj.get("intensities") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner.py new file mode 100644 index 00000000..5cf0b312 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_grains200_response_intermediate_inner_intensities_with_sequestration import PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration +from typing import Optional, Set +from typing_extensions import Self + +class PostGrains200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Grains calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + intensities_with_sequestration: PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration = Field(alias="intensitiesWithSequestration") + net: PostAquaculture200ResponseNet + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "intensitiesWithSequestration", "net", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGrains200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities_with_sequestration + if self.intensities_with_sequestration: + _dict['intensitiesWithSequestration'] = self.intensities_with_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGrains200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "intensitiesWithSequestration": PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration.from_dict(obj["intensitiesWithSequestration"]) if obj.get("intensitiesWithSequestration") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner_intensities_with_sequestration.py b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner_intensities_with_sequestration.py new file mode 100644 index 00000000..c270378a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_grains200_response_intermediate_inner_intensities_with_sequestration.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration(BaseModel): + """ + PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration + """ # noqa: E501 + grain_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Grain produced in tonnes", alias="grainProducedTonnes") + grains_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Grains excluding sequestration, in t-CO2e/t grain", alias="grainsExcludingSequestration") + grains_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Grains including sequestration, in t-CO2e/t grain", alias="grainsIncludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["grainProducedTonnes", "grainsExcludingSequestration", "grainsIncludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGrains200ResponseIntermediateInnerIntensitiesWithSequestration from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "grainProducedTonnes": obj.get("grainProducedTonnes"), + "grainsExcludingSequestration": obj.get("grainsExcludingSequestration"), + "grainsIncludingSequestration": obj.get("grainsIncludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_grains_request.py b/examples/python-api-client/api-client/openapi_client/models/post_grains_request.py new file mode 100644 index 00000000..07b7d7e7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_grains_request.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from openapi_client.models.post_grains_request_crops_inner import PostGrainsRequestCropsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostGrainsRequest(BaseModel): + """ + Input data required for the `grains` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + crops: List[PostGrainsRequestCropsInner] + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + vegetation: List[PostCottonRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "crops", "electricityRenewable", "electricityUse", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGrainsRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in crops (list) + _items = [] + if self.crops: + for _item_crops in self.crops: + if _item_crops: + _items.append(_item_crops.to_dict()) + _dict['crops'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGrainsRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "crops": [PostGrainsRequestCropsInner.from_dict(_item) for _item in obj["crops"]] if obj.get("crops") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "vegetation": [PostCottonRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_grains_request_crops_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_grains_request_crops_inner.py new file mode 100644 index 00000000..89374903 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_grains_request_crops_inner.py @@ -0,0 +1,164 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostGrainsRequestCropsInner(BaseModel): + """ + PostGrainsRequestCropsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + type: StrictStr = Field(description="Crop type. Note that the following crop types are now deprecated, the relevant full calculator should be used instead: 'Cotton', 'Rice', 'Sugar Cane'") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + production_system: StrictStr = Field(description="Production system of this crop. Note that the following production systems are now deprecated, the relevant full calculator should be used instead: 'Cotton', 'Rice', 'Sugar cane'", alias="productionSystem") + average_grain_yield: Union[StrictFloat, StrictInt] = Field(description="Average grain yield, in t/ha (tonnes per hectare)", alias="averageGrainYield") + area_sown: Union[StrictFloat, StrictInt] = Field(description="Area sown, in ha (hectares)", alias="areaSown") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm", alias="rainfallAbove600") + fraction_of_annual_crop_burnt: Union[StrictFloat, StrictInt] = Field(description="Fraction of annual production of crop that is burnt, from 0 to 1", alias="fractionOfAnnualCropBurnt") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_allocation: Union[StrictFloat, StrictInt] = Field(description="Percentage of electricity use to allocate to this crop, from 0 to 1", alias="electricityAllocation") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + diesel_use: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)", alias="dieselUse") + petrol_use: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)", alias="petrolUse") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "type", "state", "productionSystem", "averageGrainYield", "areaSown", "nonUreaNitrogen", "ureaApplication", "ureaAmmoniumNitrate", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "rainfallAbove600", "fractionOfAnnualCropBurnt", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityAllocation", "limestone", "limestoneFraction", "dieselUse", "petrolUse", "lpg"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Wheat', 'Barley', 'Maize', 'Oats', 'Rice', 'Sorghum', 'Triticale', 'Other Cereals', 'Pulses', 'Tuber and Roots', 'Peanuts', 'Sugar Cane', 'Cotton', 'Hops', 'Oilseeds', 'Forage Crops', 'Lucerne', 'Other legume', 'Annual grass', 'Grass clover mixture', 'Perennial pasture']): + raise ValueError("must be one of enum values ('Wheat', 'Barley', 'Maize', 'Oats', 'Rice', 'Sorghum', 'Triticale', 'Other Cereals', 'Pulses', 'Tuber and Roots', 'Peanuts', 'Sugar Cane', 'Cotton', 'Hops', 'Oilseeds', 'Forage Crops', 'Lucerne', 'Other legume', 'Annual grass', 'Grass clover mixture', 'Perennial pasture')") + return value + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('production_system') + def production_system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Non-irrigated crop', 'Irrigated crop', 'Sugar cane', 'Cotton', 'Horticulture']): + raise ValueError("must be one of enum values ('Non-irrigated crop', 'Irrigated crop', 'Sugar cane', 'Cotton', 'Horticulture')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostGrainsRequestCropsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostGrainsRequestCropsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "type": obj.get("type"), + "state": obj.get("state"), + "productionSystem": obj.get("productionSystem"), + "averageGrainYield": obj.get("averageGrainYield"), + "areaSown": obj.get("areaSown"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen"), + "ureaApplication": obj.get("ureaApplication"), + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate"), + "phosphorusApplication": obj.get("phosphorusApplication"), + "potassiumApplication": obj.get("potassiumApplication"), + "sulfurApplication": obj.get("sulfurApplication"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "fractionOfAnnualCropBurnt": obj.get("fractionOfAnnualCropBurnt"), + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityAllocation": obj.get("electricityAllocation"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "dieselUse": obj.get("dieselUse"), + "petrolUse": obj.get("petrolUse"), + "lpg": obj.get("lpg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response.py new file mode 100644 index 00000000..693d8836 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_horticulture200_response_intermediate_inner import PostHorticulture200ResponseIntermediateInner +from openapi_client.models.post_horticulture200_response_intermediate_inner_intensities_with_sequestration import PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_horticulture200_response_scope1 import PostHorticulture200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticulture200Response(BaseModel): + """ + Emissions calculation output for the `horticulture` calculator + """ # noqa: E501 + scope1: PostHorticulture200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostHorticulture200ResponseIntermediateInner] + net: PostCotton200ResponseNet + intensities: List[PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration] = Field(description="Emissions intensity for each crop (in order)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticulture200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticulture200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostHorticulture200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostHorticulture200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostCotton200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner.py new file mode 100644 index 00000000..2f4751e0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_horticulture200_response_intermediate_inner_intensities_with_sequestration import PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration +from openapi_client.models.post_horticulture200_response_scope1 import PostHorticulture200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticulture200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Horticulture calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostHorticulture200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + intensities_with_sequestration: PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration = Field(alias="intensitiesWithSequestration") + net: PostAquaculture200ResponseNet + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "intensitiesWithSequestration", "net", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities_with_sequestration + if self.intensities_with_sequestration: + _dict['intensitiesWithSequestration'] = self.intensities_with_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostHorticulture200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "intensitiesWithSequestration": PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration.from_dict(obj["intensitiesWithSequestration"]) if obj.get("intensitiesWithSequestration") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner_intensities_with_sequestration.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner_intensities_with_sequestration.py new file mode 100644 index 00000000..9deb88d7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_intermediate_inner_intensities_with_sequestration.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration(BaseModel): + """ + Horticulture intensities output + """ # noqa: E501 + crop_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Horticultural crop produced in tonnes", alias="cropProducedTonnes") + tonnes_crop_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity excluding sequestration, in t-CO2e/t crop", alias="tonnesCropExcludingSequestration") + tonnes_crop_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity including sequestration, in t-CO2e/t crop", alias="tonnesCropIncludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["cropProducedTonnes", "tonnesCropExcludingSequestration", "tonnesCropIncludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseIntermediateInnerIntensitiesWithSequestration from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cropProducedTonnes": obj.get("cropProducedTonnes"), + "tonnesCropExcludingSequestration": obj.get("tonnesCropExcludingSequestration"), + "tonnesCropIncludingSequestration": obj.get("tonnesCropIncludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_scope1.py new file mode 100644 index 00000000..8a7ad567 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture200_response_scope1.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticulture200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + crop_residue_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from crop residue, in tonnes-CO2e", alias="cropResidueN2O") + field_burning_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from field burning, in tonnes-CO2e", alias="fieldBurningN2O") + field_burning_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from field burning, in tonnes-CO2e", alias="fieldBurningCH4") + hfcs_refrigerant_leakage: Union[StrictFloat, StrictInt] = Field(description="Emissions from refrigerant leakage, in tonnes-HFCs", alias="hfcsRefrigerantLeakage") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total_hfcs: Union[StrictFloat, StrictInt] = Field(description="Total HFCs scope 1 emissions, in tonnes-CO2e", alias="totalHFCs") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "fertiliserN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "cropResidueN2O", "fieldBurningN2O", "fieldBurningCH4", "hfcsRefrigerantLeakage", "totalCO2", "totalCH4", "totalN2O", "totalHFCs", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticulture200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "cropResidueN2O": obj.get("cropResidueN2O"), + "fieldBurningN2O": obj.get("fieldBurningN2O"), + "fieldBurningCH4": obj.get("fieldBurningCH4"), + "hfcsRefrigerantLeakage": obj.get("hfcsRefrigerantLeakage"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "totalHFCs": obj.get("totalHFCs"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request.py new file mode 100644 index 00000000..f14d5d5f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from openapi_client.models.post_horticulture_request_crops_inner import PostHorticultureRequestCropsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticultureRequest(BaseModel): + """ + Input data required for the `horticulture` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + crops: List[PostHorticultureRequestCropsInner] + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + vegetation: List[PostCottonRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "crops", "electricityRenewable", "electricityUse", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticultureRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in crops (list) + _items = [] + if self.crops: + for _item_crops in self.crops: + if _item_crops: + _items.append(_item_crops.to_dict()) + _dict['crops'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticultureRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "crops": [PostHorticultureRequestCropsInner.from_dict(_item) for _item in obj["crops"]] if obj.get("crops") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "vegetation": [PostCottonRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner.py new file mode 100644 index 00000000..a4e4ae37 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner.py @@ -0,0 +1,160 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_horticulture_request_crops_inner_refrigerants_inner import PostHorticultureRequestCropsInnerRefrigerantsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticultureRequestCropsInner(BaseModel): + """ + PostHorticultureRequestCropsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + type: StrictStr = Field(description="Crop type") + average_yield: Union[StrictFloat, StrictInt] = Field(description="Average crop yield, in t/ha (tonnes per hectare)", alias="averageYield") + area_sown: Union[StrictFloat, StrictInt] = Field(description="Area sown, in ha (hectares)", alias="areaSown") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm", alias="rainfallAbove600") + urease_inhibitor_used: Optional[StrictBool] = Field(default=None, description="Urease inhibitor used. Deprecation note: No longer used (since v1.1.0)", alias="ureaseInhibitorUsed") + nitrification_inhibitor_used: Optional[StrictBool] = Field(default=None, description="Nitrification inhibitor used. Deprecation note: No longer used (since v1.1.0)", alias="nitrificationInhibitorUsed") + fraction_of_annual_crop_burnt: Union[StrictFloat, StrictInt] = Field(description="Fraction of annual production of crop that is burnt, from 0 to 1", alias="fractionOfAnnualCropBurnt") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_allocation: Union[StrictFloat, StrictInt] = Field(description="Percentage of electricity use to allocate to this crop, from 0 to 1", alias="electricityAllocation") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + diesel_use: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)", alias="dieselUse") + petrol_use: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)", alias="petrolUse") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + refrigerants: List[PostHorticultureRequestCropsInnerRefrigerantsInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "type", "averageYield", "areaSown", "ureaApplication", "nonUreaNitrogen", "ureaAmmoniumNitrate", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "rainfallAbove600", "ureaseInhibitorUsed", "nitrificationInhibitorUsed", "fractionOfAnnualCropBurnt", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityAllocation", "limestone", "limestoneFraction", "dieselUse", "petrolUse", "lpg", "refrigerants"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Pulses', 'Tuber and Roots', 'Peanuts', 'Hops', 'Perennial Hort', 'Annual Hort']): + raise ValueError("must be one of enum values ('Pulses', 'Tuber and Roots', 'Peanuts', 'Hops', 'Perennial Hort', 'Annual Hort')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticultureRequestCropsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in refrigerants (list) + _items = [] + if self.refrigerants: + for _item_refrigerants in self.refrigerants: + if _item_refrigerants: + _items.append(_item_refrigerants.to_dict()) + _dict['refrigerants'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticultureRequestCropsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "type": obj.get("type"), + "averageYield": obj.get("averageYield"), + "areaSown": obj.get("areaSown"), + "ureaApplication": obj.get("ureaApplication"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen"), + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate"), + "phosphorusApplication": obj.get("phosphorusApplication"), + "potassiumApplication": obj.get("potassiumApplication"), + "sulfurApplication": obj.get("sulfurApplication"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "ureaseInhibitorUsed": obj.get("ureaseInhibitorUsed"), + "nitrificationInhibitorUsed": obj.get("nitrificationInhibitorUsed"), + "fractionOfAnnualCropBurnt": obj.get("fractionOfAnnualCropBurnt"), + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityAllocation": obj.get("electricityAllocation"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "dieselUse": obj.get("dieselUse"), + "petrolUse": obj.get("petrolUse"), + "lpg": obj.get("lpg"), + "refrigerants": [PostHorticultureRequestCropsInnerRefrigerantsInner.from_dict(_item) for _item in obj["refrigerants"]] if obj.get("refrigerants") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner_refrigerants_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner_refrigerants_inner.py new file mode 100644 index 00000000..3f738e5a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_horticulture_request_crops_inner_refrigerants_inner.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostHorticultureRequestCropsInnerRefrigerantsInner(BaseModel): + """ + PostHorticultureRequestCropsInnerRefrigerantsInner + """ # noqa: E501 + refrigerant: StrictStr = Field(description="Refrigerant type") + charge_size: Union[StrictFloat, StrictInt] = Field(description="Amount of refrigerant contained in the appliance, in kg", alias="chargeSize") + __properties: ClassVar[List[str]] = ["refrigerant", "chargeSize"] + + @field_validator('refrigerant') + def refrigerant_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A']): + raise ValueError("must be one of enum values ('HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostHorticultureRequestCropsInnerRefrigerantsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostHorticultureRequestCropsInnerRefrigerantsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "refrigerant": obj.get("refrigerant"), + "chargeSize": obj.get("chargeSize") + }) + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response.py new file mode 100644 index 00000000..ee202849 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_pork200_response_intensities import PostPork200ResponseIntensities +from openapi_client.models.post_pork200_response_intermediate_inner import PostPork200ResponseIntermediateInner +from openapi_client.models.post_pork200_response_net import PostPork200ResponseNet +from openapi_client.models.post_pork200_response_scope1 import PostPork200ResponseScope1 +from openapi_client.models.post_pork200_response_scope3 import PostPork200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200Response(BaseModel): + """ + Emissions calculation output for the `pork` calculator + """ # noqa: E501 + scope1: PostPork200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostPork200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + net: PostPork200ResponseNet + intensities: PostPork200ResponseIntensities + intermediate: List[PostPork200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostPork200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostPork200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "net": PostPork200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostPork200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "intermediate": [PostPork200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intensities.py new file mode 100644 index 00000000..d4683539 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200ResponseIntensities(BaseModel): + """ + PostPork200ResponseIntensities + """ # noqa: E501 + pork_meat_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Pork meat including carbon sequestration, in kg-CO2e/kg liveweight", alias="porkMeatIncludingSequestration") + pork_meat_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Pork meat excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="porkMeatExcludingSequestration") + liveweight_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Pork meat produced in kg liveweight", alias="liveweightProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["porkMeatIncludingSequestration", "porkMeatExcludingSequestration", "liveweightProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "porkMeatIncludingSequestration": obj.get("porkMeatIncludingSequestration"), + "porkMeatExcludingSequestration": obj.get("porkMeatExcludingSequestration"), + "liveweightProducedKg": obj.get("liveweightProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intermediate_inner.py new file mode 100644 index 00000000..64c5e863 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_pork200_response_intensities import PostPork200ResponseIntensities +from openapi_client.models.post_pork200_response_net import PostPork200ResponseNet +from openapi_client.models.post_pork200_response_scope1 import PostPork200ResponseScope1 +from openapi_client.models.post_pork200_response_scope3 import PostPork200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200ResponseIntermediateInner(BaseModel): + """ + PostPork200ResponseIntermediateInner + """ # noqa: E501 + id: StrictStr + scope1: PostPork200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostPork200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + net: PostPork200ResponseNet + intensities: PostPork200ResponseIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostPork200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostPork200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "net": PostPork200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostPork200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_net.py new file mode 100644 index 00000000..da3c51fb --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200ResponseNet(BaseModel): + """ + Net emissions for pork + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope1.py new file mode 100644 index 00000000..4ff03406 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope1.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + enteric_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from enteric fermentation, in tonnes-CO2e", alias="entericCH4") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + manure_management_direct_n2_o: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management (direct), in tonnes-CO2e", alias="manureManagementDirectN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + atmospheric_deposition_indirect_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition indirect, in tonnes-CO2e", alias="atmosphericDepositionIndirectN2O") + leaching_and_runoff_soil_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffSoilN2O") + leaching_and_runoff_mmsn2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffMMSN2O") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "ureaCO2", "limeCO2", "fertiliserN2O", "entericCH4", "manureManagementCH4", "manureManagementDirectN2O", "atmosphericDepositionN2O", "atmosphericDepositionIndirectN2O", "leachingAndRunoffSoilN2O", "leachingAndRunoffMMSN2O", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "ureaCO2": obj.get("ureaCO2"), + "limeCO2": obj.get("limeCO2"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "entericCH4": obj.get("entericCH4"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "manureManagementDirectN2O": obj.get("manureManagementDirectN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "atmosphericDepositionIndirectN2O": obj.get("atmosphericDepositionIndirectN2O"), + "leachingAndRunoffSoilN2O": obj.get("leachingAndRunoffSoilN2O"), + "leachingAndRunoffMMSN2O": obj.get("leachingAndRunoffMMSN2O"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope3.py new file mode 100644 index 00000000..7f1bde37 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork200_response_scope3.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPork200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + purchased_feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased feed, in tonnes-CO2e", alias="purchasedFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + purchased_livestock: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased pigs, in tonnes-CO2e", alias="purchasedLivestock") + bedding: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased bedding, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "purchasedFeed", "herbicide", "electricity", "fuel", "lime", "purchasedLivestock", "bedding", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPork200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPork200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "purchasedFeed": obj.get("purchasedFeed"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "purchasedLivestock": obj.get("purchasedLivestock"), + "bedding": obj.get("bedding"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request.py new file mode 100644 index 00000000..5cecf37c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_pork_request_pork_inner import PostPorkRequestPorkInner +from openapi_client.models.post_pork_request_vegetation_inner import PostPorkRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequest(BaseModel): + """ + Input data required for the `pork` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + north_of_tropic_of_capricorn: StrictBool = Field(description="Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude. Deprecation note: This field is deprecated", alias="northOfTropicOfCapricorn") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + pork: List[PostPorkRequestPorkInner] + vegetation: List[PostPorkRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "northOfTropicOfCapricorn", "rainfallAbove600", "pork", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in pork (list) + _items = [] + if self.pork: + for _item_pork in self.pork: + if _item_pork: + _items.append(_item_pork.to_dict()) + _dict['pork'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "northOfTropicOfCapricorn": obj.get("northOfTropicOfCapricorn"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "pork": [PostPorkRequestPorkInner.from_dict(_item) for _item in obj["pork"]] if obj.get("pork") is not None else None, + "vegetation": [PostPorkRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner.py new file mode 100644 index 00000000..602deb10 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner.py @@ -0,0 +1,153 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_pork_request_pork_inner_classes import PostPorkRequestPorkInnerClasses +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner import PostPorkRequestPorkInnerFeedProductsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInner(BaseModel): + """ + PostPorkRequestPorkInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostPorkRequestPorkInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + bedding_hay_barley_straw: Union[StrictFloat, StrictInt] = Field(description="Hay, barley, straw, etc. purchased for pig bedding, in tonnes", alias="beddingHayBarleyStraw") + feed_products: List[PostPorkRequestPorkInnerFeedProductsInner] = Field(alias="feedProducts") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "herbicide", "herbicideOther", "beddingHayBarleyStraw", "feedProducts"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in feed_products (list) + _items = [] + if self.feed_products: + for _item_feed_products in self.feed_products: + if _item_feed_products: + _items.append(_item_feed_products.to_dict()) + _dict['feedProducts'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostPorkRequestPorkInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "beddingHayBarleyStraw": obj.get("beddingHayBarleyStraw"), + "feedProducts": [PostPorkRequestPorkInnerFeedProductsInner.from_dict(_item) for _item in obj["feedProducts"]] if obj.get("feedProducts") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes.py new file mode 100644 index 00000000..a2458fe1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes.py @@ -0,0 +1,141 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_pork_request_pork_inner_classes_boars import PostPorkRequestPorkInnerClassesBoars +from openapi_client.models.post_pork_request_pork_inner_classes_gilts import PostPorkRequestPorkInnerClassesGilts +from openapi_client.models.post_pork_request_pork_inner_classes_growers import PostPorkRequestPorkInnerClassesGrowers +from openapi_client.models.post_pork_request_pork_inner_classes_slaughter_pigs import PostPorkRequestPorkInnerClassesSlaughterPigs +from openapi_client.models.post_pork_request_pork_inner_classes_sows import PostPorkRequestPorkInnerClassesSows +from openapi_client.models.post_pork_request_pork_inner_classes_suckers import PostPorkRequestPorkInnerClassesSuckers +from openapi_client.models.post_pork_request_pork_inner_classes_weaners import PostPorkRequestPorkInnerClassesWeaners +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClasses(BaseModel): + """ + Pork classes of different types + """ # noqa: E501 + sows: Optional[PostPorkRequestPorkInnerClassesSows] = None + boars: Optional[PostPorkRequestPorkInnerClassesBoars] = None + gilts: Optional[PostPorkRequestPorkInnerClassesGilts] = None + suckers: Optional[PostPorkRequestPorkInnerClassesSuckers] = None + weaners: Optional[PostPorkRequestPorkInnerClassesWeaners] = None + growers: Optional[PostPorkRequestPorkInnerClassesGrowers] = None + slaughter_pigs: Optional[PostPorkRequestPorkInnerClassesSlaughterPigs] = Field(default=None, alias="slaughterPigs") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["sows", "boars", "gilts", "suckers", "weaners", "growers", "slaughterPigs"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of sows + if self.sows: + _dict['sows'] = self.sows.to_dict() + # override the default output from pydantic by calling `to_dict()` of boars + if self.boars: + _dict['boars'] = self.boars.to_dict() + # override the default output from pydantic by calling `to_dict()` of gilts + if self.gilts: + _dict['gilts'] = self.gilts.to_dict() + # override the default output from pydantic by calling `to_dict()` of suckers + if self.suckers: + _dict['suckers'] = self.suckers.to_dict() + # override the default output from pydantic by calling `to_dict()` of weaners + if self.weaners: + _dict['weaners'] = self.weaners.to_dict() + # override the default output from pydantic by calling `to_dict()` of growers + if self.growers: + _dict['growers'] = self.growers.to_dict() + # override the default output from pydantic by calling `to_dict()` of slaughter_pigs + if self.slaughter_pigs: + _dict['slaughterPigs'] = self.slaughter_pigs.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "sows": PostPorkRequestPorkInnerClassesSows.from_dict(obj["sows"]) if obj.get("sows") is not None else None, + "boars": PostPorkRequestPorkInnerClassesBoars.from_dict(obj["boars"]) if obj.get("boars") is not None else None, + "gilts": PostPorkRequestPorkInnerClassesGilts.from_dict(obj["gilts"]) if obj.get("gilts") is not None else None, + "suckers": PostPorkRequestPorkInnerClassesSuckers.from_dict(obj["suckers"]) if obj.get("suckers") is not None else None, + "weaners": PostPorkRequestPorkInnerClassesWeaners.from_dict(obj["weaners"]) if obj.get("weaners") is not None else None, + "growers": PostPorkRequestPorkInnerClassesGrowers.from_dict(obj["growers"]) if obj.get("growers") is not None else None, + "slaughterPigs": PostPorkRequestPorkInnerClassesSlaughterPigs.from_dict(obj["slaughterPigs"]) if obj.get("slaughterPigs") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_boars.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_boars.py new file mode 100644 index 00000000..4dedd50e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_boars.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesBoars(BaseModel): + """ + Boars + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesBoars from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesBoars from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_gilts.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_gilts.py new file mode 100644 index 00000000..446abd5b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_gilts.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesGilts(BaseModel): + """ + Gilts + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesGilts from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesGilts from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_growers.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_growers.py new file mode 100644 index 00000000..d5f93708 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_growers.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesGrowers(BaseModel): + """ + Growers + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesGrowers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesGrowers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_slaughter_pigs.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_slaughter_pigs.py new file mode 100644 index 00000000..ba6c67c3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_slaughter_pigs.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesSlaughterPigs(BaseModel): + """ + Slaughter Pigs + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSlaughterPigs from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSlaughterPigs from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows.py new file mode 100644 index 00000000..af573412 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesSows(BaseModel): + """ + Sows + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSows from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSows from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure.py new file mode 100644 index 00000000..e12e1e20 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure_spring import PostPorkRequestPorkInnerClassesSowsManureSpring +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesSowsManure(BaseModel): + """ + PostPorkRequestPorkInnerClassesSowsManure + """ # noqa: E501 + spring: PostPorkRequestPorkInnerClassesSowsManureSpring + summer: PostPorkRequestPorkInnerClassesSowsManureSpring + autumn: PostPorkRequestPorkInnerClassesSowsManureSpring + winter: PostPorkRequestPorkInnerClassesSowsManureSpring + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["spring", "summer", "autumn", "winter"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSowsManure from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSowsManure from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "spring": PostPorkRequestPorkInnerClassesSowsManureSpring.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostPorkRequestPorkInnerClassesSowsManureSpring.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "autumn": PostPorkRequestPorkInnerClassesSowsManureSpring.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostPorkRequestPorkInnerClassesSowsManureSpring.from_dict(obj["winter"]) if obj.get("winter") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure_spring.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure_spring.py new file mode 100644 index 00000000..14ae5a04 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_sows_manure_spring.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesSowsManureSpring(BaseModel): + """ + PostPorkRequestPorkInnerClassesSowsManureSpring + """ # noqa: E501 + outdoor_systems: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount of volatile solids sent to outoor systems in t (tonnes)", alias="outdoorSystems") + covered_anaerobic_pond: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount of volatile solids sent to covered anaerobic pond in t (tonnes)", alias="coveredAnaerobicPond") + uncovered_anaerobic_pond: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount of volatile solids sent to uncovered anaerobic pond in t (tonnes)", alias="uncoveredAnaerobicPond") + deep_litter: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount of volatile solids sent to deep litter in t (tonnes)", alias="deepLitter") + undefined_system: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount of volatile solids where manure management system is not known or defined, in t (tonnes)", alias="undefinedSystem") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["outdoorSystems", "coveredAnaerobicPond", "uncoveredAnaerobicPond", "deepLitter", "undefinedSystem"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSowsManureSpring from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSowsManureSpring from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "outdoorSystems": obj.get("outdoorSystems"), + "coveredAnaerobicPond": obj.get("coveredAnaerobicPond"), + "uncoveredAnaerobicPond": obj.get("uncoveredAnaerobicPond"), + "deepLitter": obj.get("deepLitter"), + "undefinedSystem": obj.get("undefinedSystem") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_suckers.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_suckers.py new file mode 100644 index 00000000..0b0a37ca --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_suckers.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesSuckers(BaseModel): + """ + Suckers + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSuckers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesSuckers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_weaners.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_weaners.py new file mode 100644 index 00000000..58977d0a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_classes_weaners.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_pork_request_pork_inner_classes_sows_manure import PostPorkRequestPorkInnerClassesSowsManure +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerClassesWeaners(BaseModel): + """ + Weaners + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Pig numbers in summer") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + manure: PostPorkRequestPorkInnerClassesSowsManure + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases", "manure"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesWeaners from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # override the default output from pydantic by calling `to_dict()` of manure + if self.manure: + _dict['manure'] = self.manure.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerClassesWeaners from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None, + "manure": PostPorkRequestPorkInnerClassesSowsManure.from_dict(obj["manure"]) if obj.get("manure") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner.py new file mode 100644 index 00000000..01268972 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_pork_request_pork_inner_feed_products_inner_ingredients import PostPorkRequestPorkInnerFeedProductsInnerIngredients +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerFeedProductsInner(BaseModel): + """ + Pig feed product + """ # noqa: E501 + feed_purchased: Union[StrictFloat, StrictInt] = Field(description="Pig feed purchased, in tonnes", alias="feedPurchased") + additional_ingredients: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Fraction of additional ingredient in feed mix, from 0 to 1", alias="additionalIngredients") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of feed product in GHG (kg CO2-e/kg input)", alias="emissionsIntensity") + ingredients: PostPorkRequestPorkInnerFeedProductsInnerIngredients + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["feedPurchased", "additionalIngredients", "emissionsIntensity", "ingredients"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerFeedProductsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of ingredients + if self.ingredients: + _dict['ingredients'] = self.ingredients.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerFeedProductsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "feedPurchased": obj.get("feedPurchased"), + "additionalIngredients": obj.get("additionalIngredients"), + "emissionsIntensity": obj.get("emissionsIntensity"), + "ingredients": PostPorkRequestPorkInnerFeedProductsInnerIngredients.from_dict(obj["ingredients"]) if obj.get("ingredients") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner_ingredients.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner_ingredients.py new file mode 100644 index 00000000..cf6c9a50 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_pork_inner_feed_products_inner_ingredients.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestPorkInnerFeedProductsInnerIngredients(BaseModel): + """ + Feed product ingredients, each ingredient is a fraction from 0 to 1 + """ # noqa: E501 + wheat: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = None + barley: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = None + whey_powder: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="wheyPowder") + canola_meal: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="canolaMeal") + soybean_meal: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="soybeanMeal") + meat_meal: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="meatMeal") + blood_meal: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="bloodMeal") + fishmeal: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = None + tallow: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = None + wheat_bran: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="wheatBran") + beet_pulp: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="beetPulp") + mill_mix: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=None, alias="millMix") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["wheat", "barley", "wheyPowder", "canolaMeal", "soybeanMeal", "meatMeal", "bloodMeal", "fishmeal", "tallow", "wheatBran", "beetPulp", "millMix"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerFeedProductsInnerIngredients from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestPorkInnerFeedProductsInnerIngredients from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "wheat": obj.get("wheat"), + "barley": obj.get("barley"), + "wheyPowder": obj.get("wheyPowder"), + "canolaMeal": obj.get("canolaMeal"), + "soybeanMeal": obj.get("soybeanMeal"), + "meatMeal": obj.get("meatMeal"), + "bloodMeal": obj.get("bloodMeal"), + "fishmeal": obj.get("fishmeal"), + "tallow": obj.get("tallow"), + "wheatBran": obj.get("wheatBran"), + "beetPulp": obj.get("beetPulp"), + "millMix": obj.get("millMix") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_pork_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_vegetation_inner.py new file mode 100644 index 00000000..e64891a3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_pork_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostPorkRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs allocated to a particular activity type + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + allocated_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to the activity", alias="allocatedProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "allocatedProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPorkRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPorkRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "allocatedProportion": obj.get("allocatedProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response.py new file mode 100644 index 00000000..e5befe4f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_poultry200_response_intensities import PostPoultry200ResponseIntensities +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner import PostPoultry200ResponseIntermediateBroilersInner +from openapi_client.models.post_poultry200_response_intermediate_layers_inner import PostPoultry200ResponseIntermediateLayersInner +from openapi_client.models.post_poultry200_response_net import PostPoultry200ResponseNet +from openapi_client.models.post_poultry200_response_scope1 import PostPoultry200ResponseScope1 +from openapi_client.models.post_poultry200_response_scope3 import PostPoultry200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200Response(BaseModel): + """ + Emissions calculation output for the `poultry` calculator + """ # noqa: E501 + scope1: PostPoultry200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostPoultry200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate_broilers: List[PostPoultry200ResponseIntermediateBroilersInner] = Field(alias="intermediateBroilers") + intermediate_layers: List[PostPoultry200ResponseIntermediateLayersInner] = Field(alias="intermediateLayers") + net: PostPoultry200ResponseNet + intensities: PostPoultry200ResponseIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediateBroilers", "intermediateLayers", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate_broilers (list) + _items = [] + if self.intermediate_broilers: + for _item_intermediate_broilers in self.intermediate_broilers: + if _item_intermediate_broilers: + _items.append(_item_intermediate_broilers.to_dict()) + _dict['intermediateBroilers'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in intermediate_layers (list) + _items = [] + if self.intermediate_layers: + for _item_intermediate_layers in self.intermediate_layers: + if _item_intermediate_layers: + _items.append(_item_intermediate_layers.to_dict()) + _dict['intermediateLayers'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostPoultry200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostPoultry200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediateBroilers": [PostPoultry200ResponseIntermediateBroilersInner.from_dict(_item) for _item in obj["intermediateBroilers"]] if obj.get("intermediateBroilers") is not None else None, + "intermediateLayers": [PostPoultry200ResponseIntermediateLayersInner.from_dict(_item) for _item in obj["intermediateLayers"]] if obj.get("intermediateLayers") is not None else None, + "net": PostPoultry200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostPoultry200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intensities.py new file mode 100644 index 00000000..1e8a76ea --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intensities.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseIntensities(BaseModel): + """ + PostPoultry200ResponseIntensities + """ # noqa: E501 + poultry_meat_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry meat including carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryMeatIncludingSequestration") + poultry_meat_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry meat excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryMeatExcludingSequestration") + poultry_eggs_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry eggs including carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryEggsIncludingSequestration") + poultry_eggs_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry eggs excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryEggsExcludingSequestration") + meat_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Poultry meat produced in kg", alias="meatProducedKg") + eggs_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Amount of eggs produced, in kg", alias="eggsProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["poultryMeatIncludingSequestration", "poultryMeatExcludingSequestration", "poultryEggsIncludingSequestration", "poultryEggsExcludingSequestration", "meatProducedKg", "eggsProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "poultryMeatIncludingSequestration": obj.get("poultryMeatIncludingSequestration"), + "poultryMeatExcludingSequestration": obj.get("poultryMeatExcludingSequestration"), + "poultryEggsIncludingSequestration": obj.get("poultryEggsIncludingSequestration"), + "poultryEggsExcludingSequestration": obj.get("poultryEggsExcludingSequestration"), + "meatProducedKg": obj.get("meatProducedKg"), + "eggsProducedKg": obj.get("eggsProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner.py new file mode 100644 index 00000000..4f859417 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_poultry200_response_intermediate_broilers_inner_intensities import PostPoultry200ResponseIntermediateBroilersInnerIntensities +from openapi_client.models.post_poultry200_response_scope1 import PostPoultry200ResponseScope1 +from openapi_client.models.post_poultry200_response_scope3 import PostPoultry200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseIntermediateBroilersInner(BaseModel): + """ + PostPoultry200ResponseIntermediateBroilersInner + """ # noqa: E501 + id: StrictStr + scope1: PostPoultry200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostPoultry200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + intensities: PostPoultry200ResponseIntermediateBroilersInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateBroilersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateBroilersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostPoultry200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostPoultry200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intensities": PostPoultry200ResponseIntermediateBroilersInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner_intensities.py new file mode 100644 index 00000000..d42e541b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_broilers_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseIntermediateBroilersInnerIntensities(BaseModel): + """ + PostPoultry200ResponseIntermediateBroilersInnerIntensities + """ # noqa: E501 + poultry_meat_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry meat including carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryMeatIncludingSequestration") + poultry_meat_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry meat excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="poultryMeatExcludingSequestration") + meat_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Poultry meat produced in kg liveweight", alias="meatProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["poultryMeatIncludingSequestration", "poultryMeatExcludingSequestration", "meatProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateBroilersInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateBroilersInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "poultryMeatIncludingSequestration": obj.get("poultryMeatIncludingSequestration"), + "poultryMeatExcludingSequestration": obj.get("poultryMeatExcludingSequestration"), + "meatProducedKg": obj.get("meatProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner.py new file mode 100644 index 00000000..59884c9d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_poultry200_response_intermediate_layers_inner_intensities import PostPoultry200ResponseIntermediateLayersInnerIntensities +from openapi_client.models.post_poultry200_response_scope1 import PostPoultry200ResponseScope1 +from openapi_client.models.post_poultry200_response_scope3 import PostPoultry200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseIntermediateLayersInner(BaseModel): + """ + PostPoultry200ResponseIntermediateLayersInner + """ # noqa: E501 + id: StrictStr + scope1: PostPoultry200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostPoultry200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + intensities: PostPoultry200ResponseIntermediateLayersInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateLayersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateLayersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostPoultry200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostPoultry200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intensities": PostPoultry200ResponseIntermediateLayersInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner_intensities.py new file mode 100644 index 00000000..5efaac15 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_intermediate_layers_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseIntermediateLayersInnerIntensities(BaseModel): + """ + PostPoultry200ResponseIntermediateLayersInnerIntensities + """ # noqa: E501 + poultry_eggs_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry eggs including carbon sequestration, in kg-CO2e/kg eggs", alias="poultryEggsIncludingSequestration") + poultry_eggs_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Poultry eggs excluding carbon sequestration, in kg-CO2e/kg eggs", alias="poultryEggsExcludingSequestration") + eggs_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Poultry eggs produced in kg", alias="eggsProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["poultryEggsIncludingSequestration", "poultryEggsExcludingSequestration", "eggsProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateLayersInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseIntermediateLayersInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "poultryEggsIncludingSequestration": obj.get("poultryEggsIncludingSequestration"), + "poultryEggsExcludingSequestration": obj.get("poultryEggsExcludingSequestration"), + "eggsProducedKg": obj.get("eggsProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_net.py new file mode 100644 index 00000000..6a77506d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_net.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseNet(BaseModel): + """ + PostPoultry200ResponseNet + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Total net emissions of this activity, in tonnes-CO2e/year") + broilers: Union[StrictFloat, StrictInt] = Field(description="Net emissions of broilers, in tonnes-CO2e/year") + layers: Union[StrictFloat, StrictInt] = Field(description="Net emissions of layers, in tonnes-CO2e/year") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "broilers", "layers"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "broilers": obj.get("broilers"), + "layers": obj.get("layers") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope1.py new file mode 100644 index 00000000..05ecba1c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope1.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + manure_management_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from manure management, in tonnes-CO2e", alias="manureManagementCH4") + manure_management_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from manure management, in tonnes-CO2e", alias="manureManagementN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "manureManagementCH4", "manureManagementN2O", "atmosphericDepositionN2O", "leachingAndRunoffN2O", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "manureManagementCH4": obj.get("manureManagementCH4"), + "manureManagementN2O": obj.get("manureManagementN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope3.py new file mode 100644 index 00000000..53353892 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry200_response_scope3.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultry200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + purchased_feed: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased feed, in tonnes-CO2e", alias="purchasedFeed") + purchased_hay: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased hay, in tonnes-CO2e", alias="purchasedHay") + purchased_livestock: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased livestock, in tonnes-CO2e", alias="purchasedLivestock") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["purchasedFeed", "purchasedHay", "purchasedLivestock", "herbicide", "electricity", "fuel", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultry200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "purchasedFeed": obj.get("purchasedFeed"), + "purchasedHay": obj.get("purchasedHay"), + "purchasedLivestock": obj.get("purchasedLivestock"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request.py new file mode 100644 index 00000000..2ed0bc4d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request.py @@ -0,0 +1,142 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_poultry_request_broilers_inner import PostPoultryRequestBroilersInner +from openapi_client.models.post_poultry_request_layers_inner import PostPoultryRequestLayersInner +from openapi_client.models.post_poultry_request_vegetation_inner import PostPoultryRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequest(BaseModel): + """ + Input data required for the `poultry` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + north_of_tropic_of_capricorn: StrictBool = Field(description="Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude", alias="northOfTropicOfCapricorn") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + broilers: List[PostPoultryRequestBroilersInner] + layers: List[PostPoultryRequestLayersInner] + vegetation: List[PostPoultryRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "northOfTropicOfCapricorn", "rainfallAbove600", "broilers", "layers", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in broilers (list) + _items = [] + if self.broilers: + for _item_broilers in self.broilers: + if _item_broilers: + _items.append(_item_broilers.to_dict()) + _dict['broilers'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in layers (list) + _items = [] + if self.layers: + for _item_layers in self.layers: + if _item_layers: + _items.append(_item_layers.to_dict()) + _dict['layers'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "northOfTropicOfCapricorn": obj.get("northOfTropicOfCapricorn"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "broilers": [PostPoultryRequestBroilersInner.from_dict(_item) for _item in obj["broilers"]] if obj.get("broilers") is not None else None, + "layers": [PostPoultryRequestLayersInner.from_dict(_item) for _item in obj["layers"]] if obj.get("layers") is not None else None, + "vegetation": [PostPoultryRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner.py new file mode 100644 index 00000000..8ddf7c5f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner.py @@ -0,0 +1,175 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner import PostPoultryRequestBroilersInnerGroupsInner +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_growers_purchases import PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_layers_purchases import PostPoultryRequestBroilersInnerMeatChickenLayersPurchases +from openapi_client.models.post_poultry_request_broilers_inner_meat_other_purchases import PostPoultryRequestBroilersInnerMeatOtherPurchases +from openapi_client.models.post_poultry_request_broilers_inner_sales_inner import PostPoultryRequestBroilersInnerSalesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInner(BaseModel): + """ + PostPoultryRequestBroilersInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + groups: List[PostPoultryRequestBroilersInnerGroupsInner] + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + hay: Union[StrictFloat, StrictInt] = Field(description="Hay purchased in tonnes") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + manure_waste_allocation: Union[StrictFloat, StrictInt] = Field(description="Fraction allocation of manure waste, from 0 to 1. Note: only for pasture range, paddock and free range systems", alias="manureWasteAllocation") + waste_handled_drylot_or_storage: Union[StrictFloat, StrictInt] = Field(description="Fraction of waste handled through dryland and solid storage, from 0 to 1", alias="wasteHandledDrylotOrStorage") + litter_recycled: Union[StrictFloat, StrictInt] = Field(description="Fraction of litter recycled, from 0 to 1", alias="litterRecycled") + litter_recycle_frequency: Union[StrictFloat, StrictInt] = Field(description="Number of litter cycles per year", alias="litterRecycleFrequency") + purchased_free_range: Union[StrictFloat, StrictInt] = Field(description="Fraction of chickens purchased that are free range. Note: fraction of chickens purchased that are conventional is `1 - purchasedFreeRange`", alias="purchasedFreeRange") + meat_chicken_growers_purchases: PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases = Field(alias="meatChickenGrowersPurchases") + meat_chicken_layers_purchases: PostPoultryRequestBroilersInnerMeatChickenLayersPurchases = Field(alias="meatChickenLayersPurchases") + meat_other_purchases: PostPoultryRequestBroilersInnerMeatOtherPurchases = Field(alias="meatOtherPurchases") + sales: List[PostPoultryRequestBroilersInnerSalesInner] = Field(description="Broiler sales") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "groups", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "hay", "herbicide", "herbicideOther", "manureWasteAllocation", "wasteHandledDrylotOrStorage", "litterRecycled", "litterRecycleFrequency", "purchasedFreeRange", "meatChickenGrowersPurchases", "meatChickenLayersPurchases", "meatOtherPurchases", "sales"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in groups (list) + _items = [] + if self.groups: + for _item_groups in self.groups: + if _item_groups: + _items.append(_item_groups.to_dict()) + _dict['groups'] = _items + # override the default output from pydantic by calling `to_dict()` of meat_chicken_growers_purchases + if self.meat_chicken_growers_purchases: + _dict['meatChickenGrowersPurchases'] = self.meat_chicken_growers_purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers_purchases + if self.meat_chicken_layers_purchases: + _dict['meatChickenLayersPurchases'] = self.meat_chicken_layers_purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_other_purchases + if self.meat_other_purchases: + _dict['meatOtherPurchases'] = self.meat_other_purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in sales (list) + _items = [] + if self.sales: + for _item_sales in self.sales: + if _item_sales: + _items.append(_item_sales.to_dict()) + _dict['sales'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "groups": [PostPoultryRequestBroilersInnerGroupsInner.from_dict(_item) for _item in obj["groups"]] if obj.get("groups") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "hay": obj.get("hay"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "manureWasteAllocation": obj.get("manureWasteAllocation"), + "wasteHandledDrylotOrStorage": obj.get("wasteHandledDrylotOrStorage"), + "litterRecycled": obj.get("litterRecycled"), + "litterRecycleFrequency": obj.get("litterRecycleFrequency"), + "purchasedFreeRange": obj.get("purchasedFreeRange"), + "meatChickenGrowersPurchases": PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases.from_dict(obj["meatChickenGrowersPurchases"]) if obj.get("meatChickenGrowersPurchases") is not None else None, + "meatChickenLayersPurchases": PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.from_dict(obj["meatChickenLayersPurchases"]) if obj.get("meatChickenLayersPurchases") is not None else None, + "meatOtherPurchases": PostPoultryRequestBroilersInnerMeatOtherPurchases.from_dict(obj["meatOtherPurchases"]) if obj.get("meatOtherPurchases") is not None else None, + "sales": [PostPoultryRequestBroilersInnerSalesInner.from_dict(_item) for _item in obj["sales"]] if obj.get("sales") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner.py new file mode 100644 index 00000000..d3e9193f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner import PostPoultryRequestBroilersInnerGroupsInnerFeedInner +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers import PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerGroupsInner(BaseModel): + """ + Poultry broiler group + """ # noqa: E501 + meat_chicken_growers: PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers = Field(alias="meatChickenGrowers") + meat_chicken_layers: PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers = Field(alias="meatChickenLayers") + meat_other: PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers = Field(alias="meatOther") + feed: List[PostPoultryRequestBroilersInnerGroupsInnerFeedInner] + custom_feed_purchased: Union[StrictFloat, StrictInt] = Field(description="Custom feed purchased, in tonnes", alias="customFeedPurchased") + custom_feed_emission_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of custom feed in GHG (kg CO2-e/kg input)", alias="customFeedEmissionIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["meatChickenGrowers", "meatChickenLayers", "meatOther", "feed", "customFeedPurchased", "customFeedEmissionIntensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of meat_chicken_growers + if self.meat_chicken_growers: + _dict['meatChickenGrowers'] = self.meat_chicken_growers.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers + if self.meat_chicken_layers: + _dict['meatChickenLayers'] = self.meat_chicken_layers.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_other + if self.meat_other: + _dict['meatOther'] = self.meat_other.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in feed (list) + _items = [] + if self.feed: + for _item_feed in self.feed: + if _item_feed: + _items.append(_item_feed.to_dict()) + _dict['feed'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "meatChickenGrowers": PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.from_dict(obj["meatChickenGrowers"]) if obj.get("meatChickenGrowers") is not None else None, + "meatChickenLayers": PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.from_dict(obj["meatChickenLayers"]) if obj.get("meatChickenLayers") is not None else None, + "meatOther": PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers.from_dict(obj["meatOther"]) if obj.get("meatOther") is not None else None, + "feed": [PostPoultryRequestBroilersInnerGroupsInnerFeedInner.from_dict(_item) for _item in obj["feed"]] if obj.get("feed") is not None else None, + "customFeedPurchased": obj.get("customFeedPurchased"), + "customFeedEmissionIntensity": obj.get("customFeedEmissionIntensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner.py new file mode 100644 index 00000000..ff135425 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients import PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerGroupsInnerFeedInner(BaseModel): + """ + Poultry feed + """ # noqa: E501 + ingredients: PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients + feed_purchased: Union[StrictFloat, StrictInt] = Field(description="Feed purchased, in tonnes", alias="feedPurchased") + additional_ingredient: Union[StrictFloat, StrictInt] = Field(description="Fraction of additional ingredients in feed mix, from 0 to 1", alias="additionalIngredient") + emission_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of feed product in GHG (kg CO2-e/kg input)", alias="emissionIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["ingredients", "feedPurchased", "additionalIngredient", "emissionIntensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerFeedInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of ingredients + if self.ingredients: + _dict['ingredients'] = self.ingredients.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerFeedInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "ingredients": PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients.from_dict(obj["ingredients"]) if obj.get("ingredients") is not None else None, + "feedPurchased": obj.get("feedPurchased"), + "additionalIngredient": obj.get("additionalIngredient"), + "emissionIntensity": obj.get("emissionIntensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients.py new file mode 100644 index 00000000..7ff2a292 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_feed_inner_ingredients.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients(BaseModel): + """ + Poultry broiler feed ingredients as fractions, each from 0 to 1 + """ # noqa: E501 + wheat: Optional[Union[StrictFloat, StrictInt]] = None + barley: Optional[Union[StrictFloat, StrictInt]] = None + sorghum: Optional[Union[StrictFloat, StrictInt]] = None + soybean: Optional[Union[StrictFloat, StrictInt]] = None + millrun: Optional[Union[StrictFloat, StrictInt]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["wheat", "barley", "sorghum", "soybean", "millrun"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerFeedInnerIngredients from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "wheat": obj.get("wheat"), + "barley": obj.get("barley"), + "sorghum": obj.get("sorghum"), + "soybean": obj.get("soybean"), + "millrun": obj.get("millrun") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers.py new file mode 100644 index 00000000..c8f71605 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_groups_inner_meat_chicken_growers.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers(BaseModel): + """ + Broiler class with seasonal data + """ # noqa: E501 + birds: Union[StrictFloat, StrictInt] = Field(description="Total number of birds/head") + average_stay_length50: Union[StrictFloat, StrictInt] = Field(description="Average length of stay until 50% of the flock is depleted, in days", alias="averageStayLength50") + liveweight50: Union[StrictFloat, StrictInt] = Field(description="Average liveweight during the 50% depletion period, in kg") + average_stay_length100: Union[StrictFloat, StrictInt] = Field(description="Average length of stay until 100% of the flock is depleted, in days", alias="averageStayLength100") + liveweight100: Union[StrictFloat, StrictInt] = Field(description="Average liveweight during the 100% depletion period, in kg") + dry_matter_intake: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Dry matter intake, in kg/head/day", alias="dryMatterIntake") + dry_matter_digestibility: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Dry matter digestibility fraction, from 0 to 1", alias="dryMatterDigestibility") + crude_protein: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Crude protein fraction, from 0 to 1", alias="crudeProtein") + manure_ash: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Manure ash fraction, from 0 to 1", alias="manureAsh") + nitrogen_retention_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Nitrogen retention rate fraction, from 0 to 1", alias="nitrogenRetentionRate") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["birds", "averageStayLength50", "liveweight50", "averageStayLength100", "liveweight100", "dryMatterIntake", "dryMatterDigestibility", "crudeProtein", "manureAsh", "nitrogenRetentionRate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerGroupsInnerMeatChickenGrowers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "birds": obj.get("birds"), + "averageStayLength50": obj.get("averageStayLength50"), + "liveweight50": obj.get("liveweight50"), + "averageStayLength100": obj.get("averageStayLength100"), + "liveweight100": obj.get("liveweight100"), + "dryMatterIntake": obj.get("dryMatterIntake"), + "dryMatterDigestibility": obj.get("dryMatterDigestibility"), + "crudeProtein": obj.get("crudeProtein"), + "manureAsh": obj.get("manureAsh"), + "nitrogenRetentionRate": obj.get("nitrogenRetentionRate") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_growers_purchases.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_growers_purchases.py new file mode 100644 index 00000000..c0b74365 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_growers_purchases.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases(BaseModel): + """ + Livestock purchases of meat chicken growers + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatChickenGrowersPurchases from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_layers_purchases.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_layers_purchases.py new file mode 100644 index 00000000..7eb1e655 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_chicken_layers_purchases.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerMeatChickenLayersPurchases(BaseModel): + """ + Livestock purchases of meat chicken layers + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatChickenLayersPurchases from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatChickenLayersPurchases from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_other_purchases.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_other_purchases.py new file mode 100644 index 00000000..63e605a9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_meat_other_purchases.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerMeatOtherPurchases(BaseModel): + """ + Livestock purchases of meat other + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatOtherPurchases from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerMeatOtherPurchases from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_sales_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_sales_inner.py new file mode 100644 index 00000000..6a757194 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_broilers_inner_sales_inner.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_feedlot_request_feedlots_inner_sales_bulls_gt1_inner import PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestBroilersInnerSalesInner(BaseModel): + """ + Poultry broiler sales + """ # noqa: E501 + meat_chicken_growers_sales: PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner = Field(alias="meatChickenGrowersSales") + meat_chicken_layers: PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner = Field(alias="meatChickenLayers") + meat_other: PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner = Field(alias="meatOther") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["meatChickenGrowersSales", "meatChickenLayers", "meatOther"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerSalesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of meat_chicken_growers_sales + if self.meat_chicken_growers_sales: + _dict['meatChickenGrowersSales'] = self.meat_chicken_growers_sales.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers + if self.meat_chicken_layers: + _dict['meatChickenLayers'] = self.meat_chicken_layers.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_other + if self.meat_other: + _dict['meatOther'] = self.meat_other.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestBroilersInnerSalesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "meatChickenGrowersSales": PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(obj["meatChickenGrowersSales"]) if obj.get("meatChickenGrowersSales") is not None else None, + "meatChickenLayers": PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(obj["meatChickenLayers"]) if obj.get("meatChickenLayers") is not None else None, + "meatOther": PostFeedlotRequestFeedlotsInnerSalesBullsGt1Inner.from_dict(obj["meatOther"]) if obj.get("meatOther") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner.py new file mode 100644 index 00000000..c0d15b5d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner.py @@ -0,0 +1,187 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_poultry_request_broilers_inner_groups_inner_feed_inner import PostPoultryRequestBroilersInnerGroupsInnerFeedInner +from openapi_client.models.post_poultry_request_broilers_inner_meat_chicken_layers_purchases import PostPoultryRequestBroilersInnerMeatChickenLayersPurchases +from openapi_client.models.post_poultry_request_layers_inner_layers import PostPoultryRequestLayersInnerLayers +from openapi_client.models.post_poultry_request_layers_inner_layers_egg_sale import PostPoultryRequestLayersInnerLayersEggSale +from openapi_client.models.post_poultry_request_layers_inner_layers_purchases import PostPoultryRequestLayersInnerLayersPurchases +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers import PostPoultryRequestLayersInnerMeatChickenLayers +from openapi_client.models.post_poultry_request_layers_inner_meat_chicken_layers_egg_sale import PostPoultryRequestLayersInnerMeatChickenLayersEggSale +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInner(BaseModel): + """ + PostPoultryRequestLayersInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + layers: PostPoultryRequestLayersInnerLayers + meat_chicken_layers: PostPoultryRequestLayersInnerMeatChickenLayers = Field(alias="meatChickenLayers") + feed: List[PostPoultryRequestBroilersInnerGroupsInnerFeedInner] + purchased_free_range: Union[StrictFloat, StrictInt] = Field(description="Fraction of chickens purchased that are free range. Note: fraction of chickens purchased that are conventional is `1 - purchasedFreeRange`", alias="purchasedFreeRange") + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + hay: Union[StrictFloat, StrictInt] = Field(description="Hay purchased in tonnes") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + manure_waste_allocation: Union[StrictFloat, StrictInt] = Field(description="Fraction allocation of manure waste, from 0 to 1. Note: only for pasture range, paddock and free range systems", alias="manureWasteAllocation") + waste_handled_drylot_or_storage: Union[StrictFloat, StrictInt] = Field(description="Fraction of waste handled through dryland and solid storage, from 0 to 1", alias="wasteHandledDrylotOrStorage") + litter_recycled: Union[StrictFloat, StrictInt] = Field(description="Fraction of litter recycled, from 0 to 1", alias="litterRecycled") + litter_recycle_frequency: Union[StrictFloat, StrictInt] = Field(description="Number of litter cycles per year", alias="litterRecycleFrequency") + meat_chicken_layers_purchases: PostPoultryRequestBroilersInnerMeatChickenLayersPurchases = Field(alias="meatChickenLayersPurchases") + layers_purchases: PostPoultryRequestLayersInnerLayersPurchases = Field(alias="layersPurchases") + custom_feed_purchased: Union[StrictFloat, StrictInt] = Field(description="Custom feed purchased, in tonnes", alias="customFeedPurchased") + custom_feed_emission_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of custom feed in GHG (kg CO2-e/kg input)", alias="customFeedEmissionIntensity") + meat_chicken_layers_egg_sale: PostPoultryRequestLayersInnerMeatChickenLayersEggSale = Field(alias="meatChickenLayersEggSale") + layers_egg_sale: PostPoultryRequestLayersInnerLayersEggSale = Field(alias="layersEggSale") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "layers", "meatChickenLayers", "feed", "purchasedFreeRange", "diesel", "petrol", "lpg", "electricitySource", "electricityRenewable", "electricityUse", "hay", "herbicide", "herbicideOther", "manureWasteAllocation", "wasteHandledDrylotOrStorage", "litterRecycled", "litterRecycleFrequency", "meatChickenLayersPurchases", "layersPurchases", "customFeedPurchased", "customFeedEmissionIntensity", "meatChickenLayersEggSale", "layersEggSale"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of layers + if self.layers: + _dict['layers'] = self.layers.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers + if self.meat_chicken_layers: + _dict['meatChickenLayers'] = self.meat_chicken_layers.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in feed (list) + _items = [] + if self.feed: + for _item_feed in self.feed: + if _item_feed: + _items.append(_item_feed.to_dict()) + _dict['feed'] = _items + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers_purchases + if self.meat_chicken_layers_purchases: + _dict['meatChickenLayersPurchases'] = self.meat_chicken_layers_purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of layers_purchases + if self.layers_purchases: + _dict['layersPurchases'] = self.layers_purchases.to_dict() + # override the default output from pydantic by calling `to_dict()` of meat_chicken_layers_egg_sale + if self.meat_chicken_layers_egg_sale: + _dict['meatChickenLayersEggSale'] = self.meat_chicken_layers_egg_sale.to_dict() + # override the default output from pydantic by calling `to_dict()` of layers_egg_sale + if self.layers_egg_sale: + _dict['layersEggSale'] = self.layers_egg_sale.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "layers": PostPoultryRequestLayersInnerLayers.from_dict(obj["layers"]) if obj.get("layers") is not None else None, + "meatChickenLayers": PostPoultryRequestLayersInnerMeatChickenLayers.from_dict(obj["meatChickenLayers"]) if obj.get("meatChickenLayers") is not None else None, + "feed": [PostPoultryRequestBroilersInnerGroupsInnerFeedInner.from_dict(_item) for _item in obj["feed"]] if obj.get("feed") is not None else None, + "purchasedFreeRange": obj.get("purchasedFreeRange"), + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "hay": obj.get("hay"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "manureWasteAllocation": obj.get("manureWasteAllocation"), + "wasteHandledDrylotOrStorage": obj.get("wasteHandledDrylotOrStorage"), + "litterRecycled": obj.get("litterRecycled"), + "litterRecycleFrequency": obj.get("litterRecycleFrequency"), + "meatChickenLayersPurchases": PostPoultryRequestBroilersInnerMeatChickenLayersPurchases.from_dict(obj["meatChickenLayersPurchases"]) if obj.get("meatChickenLayersPurchases") is not None else None, + "layersPurchases": PostPoultryRequestLayersInnerLayersPurchases.from_dict(obj["layersPurchases"]) if obj.get("layersPurchases") is not None else None, + "customFeedPurchased": obj.get("customFeedPurchased"), + "customFeedEmissionIntensity": obj.get("customFeedEmissionIntensity"), + "meatChickenLayersEggSale": PostPoultryRequestLayersInnerMeatChickenLayersEggSale.from_dict(obj["meatChickenLayersEggSale"]) if obj.get("meatChickenLayersEggSale") is not None else None, + "layersEggSale": PostPoultryRequestLayersInnerLayersEggSale.from_dict(obj["layersEggSale"]) if obj.get("layersEggSale") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers.py new file mode 100644 index 00000000..4a0ccea6 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInnerLayers(BaseModel): + """ + Layers + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in summer") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_egg_sale.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_egg_sale.py new file mode 100644 index 00000000..bd4665b5 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_egg_sale.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInnerLayersEggSale(BaseModel): + """ + Layers egg sales + """ # noqa: E501 + eggs_produced: Union[StrictFloat, StrictInt] = Field(description="Number of eggs produced in a year per bird", alias="eggsProduced") + average_weight: Union[StrictFloat, StrictInt] = Field(description="Average egg weight in grams", alias="averageWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["eggsProduced", "averageWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayersEggSale from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayersEggSale from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "eggsProduced": obj.get("eggsProduced"), + "averageWeight": obj.get("averageWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_purchases.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_purchases.py new file mode 100644 index 00000000..6f60ed5f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_layers_purchases.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInnerLayersPurchases(BaseModel): + """ + Livestock purchases of layers + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals purchased (head)") + purchase_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at purchase, in liveweight kg/head (kilogram per head)", alias="purchaseWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "purchaseWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayersPurchases from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerLayersPurchases from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "purchaseWeight": obj.get("purchaseWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers.py new file mode 100644 index 00000000..dfe39f30 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInnerMeatChickenLayers(BaseModel): + """ + Meat chicken layers + """ # noqa: E501 + autumn: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in autumn") + winter: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in winter") + spring: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in spring") + summer: Union[StrictFloat, StrictInt] = Field(description="Flock numbers in summer") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerMeatChickenLayers from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerMeatChickenLayers from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers_egg_sale.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers_egg_sale.py new file mode 100644 index 00000000..af234462 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_layers_inner_meat_chicken_layers_egg_sale.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestLayersInnerMeatChickenLayersEggSale(BaseModel): + """ + Meat chicken layers egg sales + """ # noqa: E501 + eggs_produced: Union[StrictFloat, StrictInt] = Field(description="Number of eggs produced in a year per bird", alias="eggsProduced") + average_weight: Union[StrictFloat, StrictInt] = Field(description="Average egg weight in grams", alias="averageWeight") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["eggsProduced", "averageWeight"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerMeatChickenLayersEggSale from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestLayersInnerMeatChickenLayersEggSale from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "eggsProduced": obj.get("eggsProduced"), + "averageWeight": obj.get("averageWeight") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_vegetation_inner.py new file mode 100644 index 00000000..11ac6eb2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_poultry_request_vegetation_inner.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostPoultryRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to broilers and layers + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + broilers_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to broilers", alias="broilersProportion") + layers_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to layers", alias="layersProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "broilersProportion", "layersProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostPoultryRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostPoultryRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "broilersProportion": obj.get("broilersProportion"), + "layersProportion": obj.get("layersProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response.py new file mode 100644 index 00000000..a0c6fb7c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_processing200_response_intensities_inner import PostProcessing200ResponseIntensitiesInner +from openapi_client.models.post_processing200_response_intermediate_inner import PostProcessing200ResponseIntermediateInner +from openapi_client.models.post_processing200_response_net import PostProcessing200ResponseNet +from openapi_client.models.post_processing200_response_scope1 import PostProcessing200ResponseScope1 +from openapi_client.models.post_processing200_response_scope3 import PostProcessing200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200Response(BaseModel): + """ + Emissions calculation output for the `processing` calculator + """ # noqa: E501 + scope1: PostProcessing200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostProcessing200ResponseScope3 + purchased_offsets: PostAquaculture200ResponsePurchasedOffsets = Field(alias="purchasedOffsets") + net: PostProcessing200ResponseNet + intensities: List[PostProcessing200ResponseIntensitiesInner] + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostProcessing200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "purchasedOffsets", "net", "intensities", "carbonSequestration", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchased_offsets + if self.purchased_offsets: + _dict['purchasedOffsets'] = self.purchased_offsets.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostProcessing200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostProcessing200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "purchasedOffsets": PostAquaculture200ResponsePurchasedOffsets.from_dict(obj["purchasedOffsets"]) if obj.get("purchasedOffsets") is not None else None, + "net": PostProcessing200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostProcessing200ResponseIntensitiesInner.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostProcessing200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intensities_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intensities_inner.py new file mode 100644 index 00000000..08feec1c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intensities_inner.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200ResponseIntensitiesInner(BaseModel): + """ + PostProcessing200ResponseIntensitiesInner + """ # noqa: E501 + units_produced: Union[StrictFloat, StrictInt] = Field(description="Number of processed product units produced", alias="unitsProduced") + unit_of_product: StrictStr = Field(description="Unit type of the product being produced (used by \"unitsProduced\")", alias="unitOfProduct") + processing_excluding_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Processing emissions intensity excluding carbon offsets, in kg-CO2e/number of units produced", alias="processingExcludingCarbonOffsets") + processing_including_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Processing emissions intensity including carbon offsets, in kg-CO2e/number of units produced", alias="processingIncludingCarbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["unitsProduced", "unitOfProduct", "processingExcludingCarbonOffsets", "processingIncludingCarbonOffsets"] + + @field_validator('unit_of_product') + def unit_of_product_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['litre', 'tonne', 'unit', 'bottle', 'dozen']): + raise ValueError("must be one of enum values ('litre', 'tonne', 'unit', 'bottle', 'dozen')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseIntensitiesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseIntensitiesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "unitsProduced": obj.get("unitsProduced"), + "unitOfProduct": obj.get("unitOfProduct"), + "processingExcludingCarbonOffsets": obj.get("processingExcludingCarbonOffsets"), + "processingIncludingCarbonOffsets": obj.get("processingIncludingCarbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intermediate_inner.py new file mode 100644 index 00000000..adb82421 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_processing200_response_intensities_inner import PostProcessing200ResponseIntensitiesInner +from openapi_client.models.post_processing200_response_scope1 import PostProcessing200ResponseScope1 +from openapi_client.models.post_processing200_response_scope3 import PostProcessing200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200ResponseIntermediateInner(BaseModel): + """ + PostProcessing200ResponseIntermediateInner + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostProcessing200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostProcessing200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + intensities: PostProcessing200ResponseIntensitiesInner + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostProcessing200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostProcessing200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intensities": PostProcessing200ResponseIntensitiesInner.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_net.py new file mode 100644 index 00000000..7e310022 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_net.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200ResponseNet(BaseModel): + """ + Net emissions for the processing activity + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope1.py new file mode 100644 index 00000000..0ef546a4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope1.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + hfcs_refrigerant_leakage: Union[StrictFloat, StrictInt] = Field(description="Emissions from refrigerant leakage, in tonnes-HFCs", alias="hfcsRefrigerantLeakage") + purchased_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased CO2, in tonnes-CO2e", alias="purchasedCO2") + wastewater_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from wastewater, in tonnes-CO2e", alias="wastewaterCO2") + composted_solid_waste_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from composted solid waste, in tonnes-CO2e", alias="compostedSolidWasteCO2") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total_hfcs: Union[StrictFloat, StrictInt] = Field(description="Total HFCs scope 1 emissions, in tonnes-CO2e", alias="totalHFCs") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "hfcsRefrigerantLeakage", "purchasedCO2", "wastewaterCO2", "compostedSolidWasteCO2", "totalCO2", "totalCH4", "totalN2O", "totalHFCs", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "hfcsRefrigerantLeakage": obj.get("hfcsRefrigerantLeakage"), + "purchasedCO2": obj.get("purchasedCO2"), + "wastewaterCO2": obj.get("wastewaterCO2"), + "compostedSolidWasteCO2": obj.get("compostedSolidWasteCO2"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "totalHFCs": obj.get("totalHFCs"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope3.py new file mode 100644 index 00000000..f0545d60 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing200_response_scope3.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessing200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + solid_waste_sent_offsite: Union[StrictFloat, StrictInt] = Field(description="Emissions from solid waste sent offsite, in tonnes-CO2e", alias="solidWasteSentOffsite") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["electricity", "fuel", "solidWasteSentOffsite", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessing200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "solidWasteSentOffsite": obj.get("solidWasteSentOffsite"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing_request.py b/examples/python-api-client/api-client/openapi_client/models/post_processing_request.py new file mode 100644 index 00000000..2ce62c82 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing_request.py @@ -0,0 +1,118 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_processing_request_products_inner import PostProcessingRequestProductsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessingRequest(BaseModel): + """ + Input data required for the `processing` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + products: List[PostProcessingRequestProductsInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "products"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessingRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in products (list) + _items = [] + if self.products: + for _item_products in self.products: + if _item_products: + _items.append(_item_products.to_dict()) + _dict['products'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessingRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "products": [PostProcessingRequestProductsInner.from_dict(_item) for _item in obj["products"]] if obj.get("products") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner.py new file mode 100644 index 00000000..5cce5572 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste +from openapi_client.models.post_horticulture_request_crops_inner_refrigerants_inner import PostHorticultureRequestCropsInnerRefrigerantsInner +from openapi_client.models.post_processing_request_products_inner_product import PostProcessingRequestProductsInnerProduct +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessingRequestProductsInner(BaseModel): + """ + Input data required for processing a specific product + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + product: PostProcessingRequestProductsInnerProduct + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + fuel: PostAquacultureRequestEnterprisesInnerFuel + refrigerants: List[PostHorticultureRequestCropsInnerRefrigerantsInner] = Field(description="Refrigerant type") + fluid_waste: List[PostAquacultureRequestEnterprisesInnerFluidWasteInner] = Field(description="Amount of fluid waste, in kL (kilolitres)", alias="fluidWaste") + solid_waste: PostAquacultureRequestEnterprisesInnerSolidWaste = Field(alias="solidWaste") + purchased_co2: Union[StrictFloat, StrictInt] = Field(description="Quantity of CO2 purchased, in kg CO2", alias="purchasedCO2") + carbon_offsets: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0)", alias="carbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "product", "electricityRenewable", "electricityUse", "electricitySource", "fuel", "refrigerants", "fluidWaste", "solidWaste", "purchasedCO2", "carbonOffsets"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessingRequestProductsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of product + if self.product: + _dict['product'] = self.product.to_dict() + # override the default output from pydantic by calling `to_dict()` of fuel + if self.fuel: + _dict['fuel'] = self.fuel.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in refrigerants (list) + _items = [] + if self.refrigerants: + for _item_refrigerants in self.refrigerants: + if _item_refrigerants: + _items.append(_item_refrigerants.to_dict()) + _dict['refrigerants'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in fluid_waste (list) + _items = [] + if self.fluid_waste: + for _item_fluid_waste in self.fluid_waste: + if _item_fluid_waste: + _items.append(_item_fluid_waste.to_dict()) + _dict['fluidWaste'] = _items + # override the default output from pydantic by calling `to_dict()` of solid_waste + if self.solid_waste: + _dict['solidWaste'] = self.solid_waste.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessingRequestProductsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "product": PostProcessingRequestProductsInnerProduct.from_dict(obj["product"]) if obj.get("product") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "electricitySource": obj.get("electricitySource"), + "fuel": PostAquacultureRequestEnterprisesInnerFuel.from_dict(obj["fuel"]) if obj.get("fuel") is not None else None, + "refrigerants": [PostHorticultureRequestCropsInnerRefrigerantsInner.from_dict(_item) for _item in obj["refrigerants"]] if obj.get("refrigerants") is not None else None, + "fluidWaste": [PostAquacultureRequestEnterprisesInnerFluidWasteInner.from_dict(_item) for _item in obj["fluidWaste"]] if obj.get("fluidWaste") is not None else None, + "solidWaste": PostAquacultureRequestEnterprisesInnerSolidWaste.from_dict(obj["solidWaste"]) if obj.get("solidWaste") is not None else None, + "purchasedCO2": obj.get("purchasedCO2"), + "carbonOffsets": obj.get("carbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner_product.py b/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner_product.py new file mode 100644 index 00000000..9d2751d2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_processing_request_products_inner_product.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostProcessingRequestProductsInnerProduct(BaseModel): + """ + Product being processed + """ # noqa: E501 + unit: StrictStr + amount_made_per_year: Union[StrictFloat, StrictInt] = Field(alias="amountMadePerYear") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["unit", "amountMadePerYear"] + + @field_validator('unit') + def unit_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['litre', 'tonne', 'unit', 'bottle', 'dozen']): + raise ValueError("must be one of enum values ('litre', 'tonne', 'unit', 'bottle', 'dozen')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostProcessingRequestProductsInnerProduct from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostProcessingRequestProductsInnerProduct from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "unit": obj.get("unit"), + "amountMadePerYear": obj.get("amountMadePerYear") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response.py new file mode 100644 index 00000000..2a58c055 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_rice200_response_intensities import PostRice200ResponseIntensities +from openapi_client.models.post_rice200_response_intermediate_inner import PostRice200ResponseIntermediateInner +from openapi_client.models.post_rice200_response_scope1 import PostRice200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostRice200Response(BaseModel): + """ + Emissions calculation output for the `rice` calculator + """ # noqa: E501 + scope1: PostRice200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostRice200ResponseIntermediateInner] + net: PostCotton200ResponseNet + intensities: PostRice200ResponseIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRice200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRice200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostRice200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostRice200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostCotton200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostRice200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intensities.py new file mode 100644 index 00000000..cd419e6b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intensities.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostRice200ResponseIntensities(BaseModel): + """ + Emissions intensities for the crop + """ # noqa: E501 + rice_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Rice produced in tonnes", alias="riceProducedTonnes") + rice_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Rice excluding sequestration, in t-CO2e/t rice", alias="riceExcludingSequestration") + rice_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Rice including sequestration, in t-CO2e/t rice", alias="riceIncludingSequestration") + intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of rice production. Deprecation note: Use `riceIncludingSequestration` instead") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["riceProducedTonnes", "riceExcludingSequestration", "riceIncludingSequestration", "intensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "riceProducedTonnes": obj.get("riceProducedTonnes"), + "riceExcludingSequestration": obj.get("riceExcludingSequestration"), + "riceIncludingSequestration": obj.get("riceIncludingSequestration"), + "intensity": obj.get("intensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner.py new file mode 100644 index 00000000..a66603df --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_rice200_response_intermediate_inner_intensities import PostRice200ResponseIntermediateInnerIntensities +from openapi_client.models.post_rice200_response_scope1 import PostRice200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostRice200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Rice calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostRice200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostRice200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostRice200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostRice200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..4ea7f094 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_intermediate_inner_intensities.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostRice200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostRice200ResponseIntermediateInnerIntensities + """ # noqa: E501 + rice_produced_tonnes: Union[StrictFloat, StrictInt] = Field(description="Rice produced in tonnes", alias="riceProducedTonnes") + rice_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Rice excluding sequestration, in t-CO2e/t rice", alias="riceExcludingSequestration") + rice_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Rice including sequestration, in t-CO2e/t rice", alias="riceIncludingSequestration") + intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of rice production. Deprecation note: Use `riceIncludingSequestration` instead") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["riceProducedTonnes", "riceExcludingSequestration", "riceIncludingSequestration", "intensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRice200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "riceProducedTonnes": obj.get("riceProducedTonnes"), + "riceExcludingSequestration": obj.get("riceExcludingSequestration"), + "riceIncludingSequestration": obj.get("riceIncludingSequestration"), + "intensity": obj.get("intensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_scope1.py new file mode 100644 index 00000000..63d5e2e4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice200_response_scope1.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostRice200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + field_burning_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from field burning, in tonnes-CO2e", alias="fieldBurningCH4") + rice_cultivation_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from rice cultivation, in tonnes-CO2e", alias="riceCultivationCH4") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + field_burning_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from field burning, in tonnes-CO2e", alias="fieldBurningN2O") + crop_residue_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from crop residue, in tonnes-CO2e", alias="cropResidueN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "limeCO2", "ureaCO2", "fieldBurningCH4", "riceCultivationCH4", "fuelCH4", "fertiliserN2O", "atmosphericDepositionN2O", "fieldBurningN2O", "cropResidueN2O", "leachingAndRunoffN2O", "fuelN2O", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRice200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRice200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "limeCO2": obj.get("limeCO2"), + "ureaCO2": obj.get("ureaCO2"), + "fieldBurningCH4": obj.get("fieldBurningCH4"), + "riceCultivationCH4": obj.get("riceCultivationCH4"), + "fuelCH4": obj.get("fuelCH4"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "fieldBurningN2O": obj.get("fieldBurningN2O"), + "cropResidueN2O": obj.get("cropResidueN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "fuelN2O": obj.get("fuelN2O"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice_request.py b/examples/python-api-client/api-client/openapi_client/models/post_rice_request.py new file mode 100644 index 00000000..d2989f09 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice_request.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from openapi_client.models.post_rice_request_crops_inner import PostRiceRequestCropsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostRiceRequest(BaseModel): + """ + Input data required for the `rice` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + crops: List[PostRiceRequestCropsInner] + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + vegetation: List[PostCottonRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "crops", "electricityRenewable", "electricityUse", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRiceRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in crops (list) + _items = [] + if self.crops: + for _item_crops in self.crops: + if _item_crops: + _items.append(_item_crops.to_dict()) + _dict['crops'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRiceRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "crops": [PostRiceRequestCropsInner.from_dict(_item) for _item in obj["crops"]] if obj.get("crops") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "vegetation": [PostCottonRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_rice_request_crops_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_rice_request_crops_inner.py new file mode 100644 index 00000000..bd85701d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_rice_request_crops_inner.py @@ -0,0 +1,174 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostRiceRequestCropsInner(BaseModel): + """ + PostRiceRequestCropsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + average_rice_yield: Union[StrictFloat, StrictInt] = Field(description="Average rice yield, in t/ha (tonnes per hectare)", alias="averageRiceYield") + area_sown: Union[StrictFloat, StrictInt] = Field(description="Area sown, in ha (hectares)", alias="areaSown") + growing_season_days: Union[StrictFloat, StrictInt] = Field(description="The length of the growing season for this crop, in days", alias="growingSeasonDays") + water_regime_type: StrictStr = Field(alias="waterRegimeType") + water_regime_sub_type: StrictStr = Field(alias="waterRegimeSubType") + rice_preseason_flooding_period: StrictStr = Field(alias="ricePreseasonFloodingPeriod") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + fraction_of_annual_crop_burnt: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Fraction of annual production of crop that is burnt, from 0 to 1", alias="fractionOfAnnualCropBurnt") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_allocation: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percentage of electricity use to allocate to this crop, from 0 to 1", alias="electricityAllocation") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + diesel_use: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)", alias="dieselUse") + petrol_use: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)", alias="petrolUse") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "averageRiceYield", "areaSown", "growingSeasonDays", "waterRegimeType", "waterRegimeSubType", "ricePreseasonFloodingPeriod", "ureaApplication", "nonUreaNitrogen", "ureaAmmoniumNitrate", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "fractionOfAnnualCropBurnt", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityAllocation", "limestone", "limestoneFraction", "dieselUse", "petrolUse", "lpg"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('water_regime_type') + def water_regime_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Upland', 'Irrigated', 'Rainfed']): + raise ValueError("must be one of enum values ('Upland', 'Irrigated', 'Rainfed')") + return value + + @field_validator('water_regime_sub_type') + def water_regime_sub_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Continuously flooded', 'Single drainage period', 'Multiple drainage periods', 'Regular rainfed', 'Drought prone', 'Deep water', 'Paddy rotation', 'Fallow without flooding in previous year']): + raise ValueError("must be one of enum values ('Continuously flooded', 'Single drainage period', 'Multiple drainage periods', 'Regular rainfed', 'Drought prone', 'Deep water', 'Paddy rotation', 'Fallow without flooding in previous year')") + return value + + @field_validator('rice_preseason_flooding_period') + def rice_preseason_flooding_period_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Non flooded pre-season < 180 days', 'Non flooded pre-season > 180 days', 'Flooded pre-season > 30 days', 'Non-flooded pre-season > 365 days']): + raise ValueError("must be one of enum values ('Non flooded pre-season < 180 days', 'Non flooded pre-season > 180 days', 'Flooded pre-season > 30 days', 'Non-flooded pre-season > 365 days')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostRiceRequestCropsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostRiceRequestCropsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "averageRiceYield": obj.get("averageRiceYield"), + "areaSown": obj.get("areaSown"), + "growingSeasonDays": obj.get("growingSeasonDays"), + "waterRegimeType": obj.get("waterRegimeType"), + "waterRegimeSubType": obj.get("waterRegimeSubType"), + "ricePreseasonFloodingPeriod": obj.get("ricePreseasonFloodingPeriod"), + "ureaApplication": obj.get("ureaApplication"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen"), + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate"), + "phosphorusApplication": obj.get("phosphorusApplication"), + "potassiumApplication": obj.get("potassiumApplication"), + "sulfurApplication": obj.get("sulfurApplication"), + "fractionOfAnnualCropBurnt": obj.get("fractionOfAnnualCropBurnt"), + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityAllocation": obj.get("electricityAllocation"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "dieselUse": obj.get("dieselUse"), + "petrolUse": obj.get("petrolUse"), + "lpg": obj.get("lpg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response.py new file mode 100644 index 00000000..56b08645 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_sheep200_response_intermediate_inner import PostSheep200ResponseIntermediateInner +from openapi_client.models.post_sheep200_response_intermediate_inner_intensities import PostSheep200ResponseIntermediateInnerIntensities +from openapi_client.models.post_sheep200_response_net import PostSheep200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostSheep200Response(BaseModel): + """ + Emissions calculation output for the `sheep` calculator + """ # noqa: E501 + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostSheep200ResponseIntermediateInner] + net: PostSheep200ResponseNet + intensities: PostSheep200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheep200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheep200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostSheep200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostSheep200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostSheep200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner.py new file mode 100644 index 00000000..3d80a728 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_buffalo200_response_scope1 import PostBuffalo200ResponseScope1 +from openapi_client.models.post_sheep200_response_intermediate_inner_intensities import PostSheep200ResponseIntermediateInnerIntensities +from typing import Optional, Set +from typing_extensions import Self + +class PostSheep200ResponseIntermediateInner(BaseModel): + """ + PostSheep200ResponseIntermediateInner + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostBuffalo200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostSheep200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheep200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheep200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostBuffalo200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostSheep200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..4f725546 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_intermediate_inner_intensities.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSheep200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostSheep200ResponseIntermediateInnerIntensities + """ # noqa: E501 + wool_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Greasy wool produced in kg", alias="woolProducedKg") + sheep_meat_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Sheep meat produced in kg liveweight", alias="sheepMeatProducedKg") + wool_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production including carbon sequestration, in kg-CO2e/kg greasy", alias="woolIncludingSequestration") + wool_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production excluding carbon sequestration, in kg-CO2e/kg greasy", alias="woolExcludingSequestration") + sheep_meat_breeding_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sheep meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight", alias="sheepMeatBreedingIncludingSequestration") + sheep_meat_breeding_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sheep meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="sheepMeatBreedingExcludingSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["woolProducedKg", "sheepMeatProducedKg", "woolIncludingSequestration", "woolExcludingSequestration", "sheepMeatBreedingIncludingSequestration", "sheepMeatBreedingExcludingSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheep200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheep200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "woolProducedKg": obj.get("woolProducedKg"), + "sheepMeatProducedKg": obj.get("sheepMeatProducedKg"), + "woolIncludingSequestration": obj.get("woolIncludingSequestration"), + "woolExcludingSequestration": obj.get("woolExcludingSequestration"), + "sheepMeatBreedingIncludingSequestration": obj.get("sheepMeatBreedingIncludingSequestration"), + "sheepMeatBreedingExcludingSequestration": obj.get("sheepMeatBreedingExcludingSequestration") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_net.py new file mode 100644 index 00000000..5275bdd9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep200_response_net.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSheep200ResponseNet(BaseModel): + """ + PostSheep200ResponseNet + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Total net emissions of this activity, in tonnes-CO2e/year") + sheep: Union[StrictFloat, StrictInt] = Field(description="Net emissions of sheep, in tonnes-CO2e/year") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "sheep"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheep200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheep200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "sheep": obj.get("sheep") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request.py new file mode 100644 index 00000000..dfd0cbac --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_sheep_request_sheep_inner import PostSheepRequestSheepInner +from openapi_client.models.post_sheep_request_vegetation_inner import PostSheepRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequest(BaseModel): + """ + Input data required for the `sheep` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + north_of_tropic_of_capricorn: StrictBool = Field(description="Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude", alias="northOfTropicOfCapricorn") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + sheep: List[PostSheepRequestSheepInner] + vegetation: List[PostSheepRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "northOfTropicOfCapricorn", "rainfallAbove600", "sheep", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in sheep (list) + _items = [] + if self.sheep: + for _item_sheep in self.sheep: + if _item_sheep: + _items.append(_item_sheep.to_dict()) + _dict['sheep'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "northOfTropicOfCapricorn": obj.get("northOfTropicOfCapricorn"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "sheep": [PostSheepRequestSheepInner.from_dict(_item) for _item in obj["sheep"]] if obj.get("sheep") is not None else None, + "vegetation": [PostSheepRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner.py new file mode 100644 index 00000000..3d0a21f3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner.py @@ -0,0 +1,165 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_beef_request_beef_inner_fertiliser import PostBeefRequestBeefInnerFertiliser +from openapi_client.models.post_beef_request_beef_inner_mineral_supplementation import PostBeefRequestBeefInnerMineralSupplementation +from openapi_client.models.post_sheep_request_sheep_inner_classes import PostSheepRequestSheepInnerClasses +from openapi_client.models.post_sheep_request_sheep_inner_ewes_lambing import PostSheepRequestSheepInnerEwesLambing +from openapi_client.models.post_sheep_request_sheep_inner_seasonal_lambing import PostSheepRequestSheepInnerSeasonalLambing +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInner(BaseModel): + """ + PostSheepRequestSheepInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + classes: PostSheepRequestSheepInnerClasses + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + fertiliser: PostBeefRequestBeefInnerFertiliser + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + mineral_supplementation: PostBeefRequestBeefInnerMineralSupplementation = Field(alias="mineralSupplementation") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + grain_feed: Union[StrictFloat, StrictInt] = Field(description="Grain purchased for cattle feed in tonnes", alias="grainFeed") + hay_feed: Union[StrictFloat, StrictInt] = Field(description="Hay purchased for cattle feed in tonnes", alias="hayFeed") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from herbicide (Paraquat, Diquat, Glyphosate) in kg (kilograms)") + herbicide_other: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients of from other herbicides in kg (kilograms)", alias="herbicideOther") + merino_percent: Union[StrictFloat, StrictInt] = Field(description="Percent of sheep purchases that are of type Merino, from 0 to 100", alias="merinoPercent") + ewes_lambing: PostSheepRequestSheepInnerEwesLambing = Field(alias="ewesLambing") + seasonal_lambing: PostSheepRequestSheepInnerSeasonalLambing = Field(alias="seasonalLambing") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "classes", "limestone", "limestoneFraction", "fertiliser", "diesel", "petrol", "lpg", "mineralSupplementation", "electricitySource", "electricityRenewable", "electricityUse", "grainFeed", "hayFeed", "herbicide", "herbicideOther", "merinoPercent", "ewesLambing", "seasonalLambing"] + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of classes + if self.classes: + _dict['classes'] = self.classes.to_dict() + # override the default output from pydantic by calling `to_dict()` of fertiliser + if self.fertiliser: + _dict['fertiliser'] = self.fertiliser.to_dict() + # override the default output from pydantic by calling `to_dict()` of mineral_supplementation + if self.mineral_supplementation: + _dict['mineralSupplementation'] = self.mineral_supplementation.to_dict() + # override the default output from pydantic by calling `to_dict()` of ewes_lambing + if self.ewes_lambing: + _dict['ewesLambing'] = self.ewes_lambing.to_dict() + # override the default output from pydantic by calling `to_dict()` of seasonal_lambing + if self.seasonal_lambing: + _dict['seasonalLambing'] = self.seasonal_lambing.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "classes": PostSheepRequestSheepInnerClasses.from_dict(obj["classes"]) if obj.get("classes") is not None else None, + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "fertiliser": PostBeefRequestBeefInnerFertiliser.from_dict(obj["fertiliser"]) if obj.get("fertiliser") is not None else None, + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "mineralSupplementation": PostBeefRequestBeefInnerMineralSupplementation.from_dict(obj["mineralSupplementation"]) if obj.get("mineralSupplementation") is not None else None, + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "grainFeed": obj.get("grainFeed"), + "hayFeed": obj.get("hayFeed"), + "herbicide": obj.get("herbicide"), + "herbicideOther": obj.get("herbicideOther"), + "merinoPercent": obj.get("merinoPercent"), + "ewesLambing": PostSheepRequestSheepInnerEwesLambing.from_dict(obj["ewesLambing"]) if obj.get("ewesLambing") is not None else None, + "seasonalLambing": PostSheepRequestSheepInnerSeasonalLambing.from_dict(obj["seasonalLambing"]) if obj.get("seasonalLambing") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes.py new file mode 100644 index 00000000..3af6f850 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes.py @@ -0,0 +1,182 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams import PostSheepRequestSheepInnerClassesRams +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_ewes import PostSheepRequestSheepInnerClassesTradeEwes +from openapi_client.models.post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets import PostSheepRequestSheepInnerClassesTradeLambsAndHoggets +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerClasses(BaseModel): + """ + PostSheepRequestSheepInnerClasses + """ # noqa: E501 + rams: Optional[PostSheepRequestSheepInnerClassesRams] = None + trade_rams: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeRams") + wethers: Optional[PostSheepRequestSheepInnerClassesRams] = None + trade_wethers: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeWethers") + maiden_breeding_ewes: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="maidenBreedingEwes") + trade_maiden_breeding_ewes: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeMaidenBreedingEwes") + breeding_ewes: PostSheepRequestSheepInnerClassesRams = Field(alias="breedingEwes") + trade_breeding_ewes: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeBreedingEwes") + other_ewes: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="otherEwes") + trade_other_ewes: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeOtherEwes") + ewe_lambs: PostSheepRequestSheepInnerClassesRams = Field(alias="eweLambs") + trade_ewe_lambs: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeEweLambs") + wether_lambs: PostSheepRequestSheepInnerClassesRams = Field(alias="wetherLambs") + trade_wether_lambs: Optional[PostSheepRequestSheepInnerClassesRams] = Field(default=None, alias="tradeWetherLambs") + trade_ewes: Optional[PostSheepRequestSheepInnerClassesTradeEwes] = Field(default=None, alias="tradeEwes") + trade_lambs_and_hoggets: Optional[PostSheepRequestSheepInnerClassesTradeLambsAndHoggets] = Field(default=None, alias="tradeLambsAndHoggets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["rams", "tradeRams", "wethers", "tradeWethers", "maidenBreedingEwes", "tradeMaidenBreedingEwes", "breedingEwes", "tradeBreedingEwes", "otherEwes", "tradeOtherEwes", "eweLambs", "tradeEweLambs", "wetherLambs", "tradeWetherLambs", "tradeEwes", "tradeLambsAndHoggets"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClasses from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of rams + if self.rams: + _dict['rams'] = self.rams.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_rams + if self.trade_rams: + _dict['tradeRams'] = self.trade_rams.to_dict() + # override the default output from pydantic by calling `to_dict()` of wethers + if self.wethers: + _dict['wethers'] = self.wethers.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_wethers + if self.trade_wethers: + _dict['tradeWethers'] = self.trade_wethers.to_dict() + # override the default output from pydantic by calling `to_dict()` of maiden_breeding_ewes + if self.maiden_breeding_ewes: + _dict['maidenBreedingEwes'] = self.maiden_breeding_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_maiden_breeding_ewes + if self.trade_maiden_breeding_ewes: + _dict['tradeMaidenBreedingEwes'] = self.trade_maiden_breeding_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of breeding_ewes + if self.breeding_ewes: + _dict['breedingEwes'] = self.breeding_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_breeding_ewes + if self.trade_breeding_ewes: + _dict['tradeBreedingEwes'] = self.trade_breeding_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of other_ewes + if self.other_ewes: + _dict['otherEwes'] = self.other_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_other_ewes + if self.trade_other_ewes: + _dict['tradeOtherEwes'] = self.trade_other_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of ewe_lambs + if self.ewe_lambs: + _dict['eweLambs'] = self.ewe_lambs.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_ewe_lambs + if self.trade_ewe_lambs: + _dict['tradeEweLambs'] = self.trade_ewe_lambs.to_dict() + # override the default output from pydantic by calling `to_dict()` of wether_lambs + if self.wether_lambs: + _dict['wetherLambs'] = self.wether_lambs.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_wether_lambs + if self.trade_wether_lambs: + _dict['tradeWetherLambs'] = self.trade_wether_lambs.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_ewes + if self.trade_ewes: + _dict['tradeEwes'] = self.trade_ewes.to_dict() + # override the default output from pydantic by calling `to_dict()` of trade_lambs_and_hoggets + if self.trade_lambs_and_hoggets: + _dict['tradeLambsAndHoggets'] = self.trade_lambs_and_hoggets.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClasses from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "rams": PostSheepRequestSheepInnerClassesRams.from_dict(obj["rams"]) if obj.get("rams") is not None else None, + "tradeRams": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeRams"]) if obj.get("tradeRams") is not None else None, + "wethers": PostSheepRequestSheepInnerClassesRams.from_dict(obj["wethers"]) if obj.get("wethers") is not None else None, + "tradeWethers": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeWethers"]) if obj.get("tradeWethers") is not None else None, + "maidenBreedingEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["maidenBreedingEwes"]) if obj.get("maidenBreedingEwes") is not None else None, + "tradeMaidenBreedingEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeMaidenBreedingEwes"]) if obj.get("tradeMaidenBreedingEwes") is not None else None, + "breedingEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["breedingEwes"]) if obj.get("breedingEwes") is not None else None, + "tradeBreedingEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeBreedingEwes"]) if obj.get("tradeBreedingEwes") is not None else None, + "otherEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["otherEwes"]) if obj.get("otherEwes") is not None else None, + "tradeOtherEwes": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeOtherEwes"]) if obj.get("tradeOtherEwes") is not None else None, + "eweLambs": PostSheepRequestSheepInnerClassesRams.from_dict(obj["eweLambs"]) if obj.get("eweLambs") is not None else None, + "tradeEweLambs": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeEweLambs"]) if obj.get("tradeEweLambs") is not None else None, + "wetherLambs": PostSheepRequestSheepInnerClassesRams.from_dict(obj["wetherLambs"]) if obj.get("wetherLambs") is not None else None, + "tradeWetherLambs": PostSheepRequestSheepInnerClassesRams.from_dict(obj["tradeWetherLambs"]) if obj.get("tradeWetherLambs") is not None else None, + "tradeEwes": PostSheepRequestSheepInnerClassesTradeEwes.from_dict(obj["tradeEwes"]) if obj.get("tradeEwes") is not None else None, + "tradeLambsAndHoggets": PostSheepRequestSheepInnerClassesTradeLambsAndHoggets.from_dict(obj["tradeLambsAndHoggets"]) if obj.get("tradeLambsAndHoggets") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams.py new file mode 100644 index 00000000..36e43f69 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams_autumn import PostSheepRequestSheepInnerClassesRamsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerClassesRams(BaseModel): + """ + PostSheepRequestSheepInnerClassesRams + """ # noqa: E501 + autumn: PostSheepRequestSheepInnerClassesRamsAutumn + winter: PostSheepRequestSheepInnerClassesRamsAutumn + spring: PostSheepRequestSheepInnerClassesRamsAutumn + summer: PostSheepRequestSheepInnerClassesRamsAutumn + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of sheep shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headShorn", "woolShorn", "cleanWoolYield", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesRams from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesRams from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams_autumn.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams_autumn.py new file mode 100644 index 00000000..325de5dd --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_rams_autumn.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerClassesRamsAutumn(BaseModel): + """ + PostSheepRequestSheepInnerClassesRamsAutumn + """ # noqa: E501 + head: Union[StrictFloat, StrictInt] = Field(description="Number of animals (head)") + liveweight: Union[StrictFloat, StrictInt] = Field(description="Average liveweight of animals in kg/head (kilogram per head)") + liveweight_gain: Union[StrictFloat, StrictInt] = Field(description="Average liveweight gain in kg/day (kilogram per day)", alias="liveweightGain") + crude_protein: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Crude protein percent, between 0 and 100", alias="crudeProtein") + dry_matter_digestibility: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Dry matter digestibility percent, between 0 and 100", alias="dryMatterDigestibility") + feed_availability: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Feed availability, in t/ha (tonnes per hectare)", alias="feedAvailability") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["head", "liveweight", "liveweightGain", "crudeProtein", "dryMatterDigestibility", "feedAvailability"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesRamsAutumn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesRamsAutumn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "head": obj.get("head"), + "liveweight": obj.get("liveweight"), + "liveweightGain": obj.get("liveweightGain"), + "crudeProtein": obj.get("crudeProtein"), + "dryMatterDigestibility": obj.get("dryMatterDigestibility"), + "feedAvailability": obj.get("feedAvailability") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_ewes.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_ewes.py new file mode 100644 index 00000000..47ff4544 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_ewes.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams_autumn import PostSheepRequestSheepInnerClassesRamsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerClassesTradeEwes(BaseModel): + """ + Trading ewes. Deprecation note: More specific trading classes are now available + """ # noqa: E501 + autumn: PostSheepRequestSheepInnerClassesRamsAutumn + winter: PostSheepRequestSheepInnerClassesRamsAutumn + spring: PostSheepRequestSheepInnerClassesRamsAutumn + summer: PostSheepRequestSheepInnerClassesRamsAutumn + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of sheep shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headShorn", "woolShorn", "cleanWoolYield", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesTradeEwes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesTradeEwes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets.py new file mode 100644 index 00000000..3938c47b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_classes_trade_lambs_and_hoggets.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.post_buffalo_request_buffalos_inner_classes_bulls_purchases_inner import PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner +from openapi_client.models.post_sheep_request_sheep_inner_classes_rams_autumn import PostSheepRequestSheepInnerClassesRamsAutumn +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerClassesTradeLambsAndHoggets(BaseModel): + """ + Trading lambs and hoggets. Deprecation note: More specific trading classes are now available + """ # noqa: E501 + autumn: PostSheepRequestSheepInnerClassesRamsAutumn + winter: PostSheepRequestSheepInnerClassesRamsAutumn + spring: PostSheepRequestSheepInnerClassesRamsAutumn + summer: PostSheepRequestSheepInnerClassesRamsAutumn + head_shorn: Union[StrictFloat, StrictInt] = Field(description="Number of sheep shorn, in head", alias="headShorn") + wool_shorn: Union[StrictFloat, StrictInt] = Field(description="Weight of wool shorn, in kg/head (kilogram per head)", alias="woolShorn") + clean_wool_yield: Union[StrictFloat, StrictInt] = Field(description="Percentage of clean wool from weight of yield, from 0 to 100", alias="cleanWoolYield") + head_purchased: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of animals purchased (head). Deprecation note: Please use `purchases` instead", alias="headPurchased") + purchased_weight: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Weight at purchase, in liveweight kg/head (kilogram per head). Deprecation note: Please use `purchases` instead", alias="purchasedWeight") + head_sold: Union[StrictFloat, StrictInt] = Field(description="Number of animals sold (head)", alias="headSold") + sale_weight: Union[StrictFloat, StrictInt] = Field(description="Weight at sale, in liveweight kg/head (kilogram per head)", alias="saleWeight") + purchases: Optional[List[PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer", "headShorn", "woolShorn", "cleanWoolYield", "headPurchased", "purchasedWeight", "headSold", "saleWeight", "purchases"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesTradeLambsAndHoggets from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of autumn + if self.autumn: + _dict['autumn'] = self.autumn.to_dict() + # override the default output from pydantic by calling `to_dict()` of winter + if self.winter: + _dict['winter'] = self.winter.to_dict() + # override the default output from pydantic by calling `to_dict()` of spring + if self.spring: + _dict['spring'] = self.spring.to_dict() + # override the default output from pydantic by calling `to_dict()` of summer + if self.summer: + _dict['summer'] = self.summer.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in purchases (list) + _items = [] + if self.purchases: + for _item_purchases in self.purchases: + if _item_purchases: + _items.append(_item_purchases.to_dict()) + _dict['purchases'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerClassesTradeLambsAndHoggets from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["autumn"]) if obj.get("autumn") is not None else None, + "winter": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["winter"]) if obj.get("winter") is not None else None, + "spring": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["spring"]) if obj.get("spring") is not None else None, + "summer": PostSheepRequestSheepInnerClassesRamsAutumn.from_dict(obj["summer"]) if obj.get("summer") is not None else None, + "headShorn": obj.get("headShorn"), + "woolShorn": obj.get("woolShorn"), + "cleanWoolYield": obj.get("cleanWoolYield"), + "headPurchased": obj.get("headPurchased"), + "purchasedWeight": obj.get("purchasedWeight"), + "headSold": obj.get("headSold"), + "saleWeight": obj.get("saleWeight"), + "purchases": [PostBuffaloRequestBuffalosInnerClassesBullsPurchasesInner.from_dict(_item) for _item in obj["purchases"]] if obj.get("purchases") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_ewes_lambing.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_ewes_lambing.py new file mode 100644 index 00000000..9d271cf9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_ewes_lambing.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerEwesLambing(BaseModel): + """ + The proportion of ewes lambing in each season, as a value from 0 to 1 + """ # noqa: E501 + autumn: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] + winter: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] + spring: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] + summer: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerEwesLambing from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerEwesLambing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_seasonal_lambing.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_seasonal_lambing.py new file mode 100644 index 00000000..e31b721b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_sheep_inner_seasonal_lambing.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestSheepInnerSeasonalLambing(BaseModel): + """ + Seasonal lamb marking rates, i.e. the rate of lambs marked per ewe lambed. Values may exceed 1 if there are more lambs marked than ewes lambed in a season. + """ # noqa: E501 + autumn: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]] + winter: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]] + spring: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]] + summer: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["autumn", "winter", "spring", "summer"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerSeasonalLambing from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestSheepInnerSeasonalLambing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "autumn": obj.get("autumn"), + "winter": obj.get("winter"), + "spring": obj.get("spring"), + "summer": obj.get("summer") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_vegetation_inner.py new file mode 100644 index 00000000..b634dbe7 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheep_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to sheep + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + sheep_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to sheep", alias="sheepProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "sheepProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "sheepProportion": obj.get("sheepProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response.py new file mode 100644 index 00000000..7f3e2fa0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response.py @@ -0,0 +1,161 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_intermediate_inner import PostBeef200ResponseIntermediateInner +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_sheep200_response_intermediate_inner import PostSheep200ResponseIntermediateInner +from openapi_client.models.post_sheepbeef200_response_intensities import PostSheepbeef200ResponseIntensities +from openapi_client.models.post_sheepbeef200_response_intermediate import PostSheepbeef200ResponseIntermediate +from openapi_client.models.post_sheepbeef200_response_net import PostSheepbeef200ResponseNet +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200Response(BaseModel): + """ + Emissions calculation output for the `sheepbeef` calculator + """ # noqa: E501 + scope1: PostBeef200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: PostSheepbeef200ResponseIntermediate + intermediate_beef: List[PostBeef200ResponseIntermediateInner] = Field(alias="intermediateBeef") + intermediate_sheep: List[PostSheep200ResponseIntermediateInner] = Field(alias="intermediateSheep") + net: PostSheepbeef200ResponseNet + intensities: PostSheepbeef200ResponseIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "intermediateBeef", "intermediateSheep", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of intermediate + if self.intermediate: + _dict['intermediate'] = self.intermediate.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate_beef (list) + _items = [] + if self.intermediate_beef: + for _item_intermediate_beef in self.intermediate_beef: + if _item_intermediate_beef: + _items.append(_item_intermediate_beef.to_dict()) + _dict['intermediateBeef'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in intermediate_sheep (list) + _items = [] + if self.intermediate_sheep: + for _item_intermediate_sheep in self.intermediate_sheep: + if _item_intermediate_sheep: + _items.append(_item_intermediate_sheep.to_dict()) + _dict['intermediateSheep'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBeef200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": PostSheepbeef200ResponseIntermediate.from_dict(obj["intermediate"]) if obj.get("intermediate") is not None else None, + "intermediateBeef": [PostBeef200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediateBeef"]] if obj.get("intermediateBeef") is not None else None, + "intermediateSheep": [PostSheep200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediateSheep"]] if obj.get("intermediateSheep") is not None else None, + "net": PostSheepbeef200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostSheepbeef200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intensities.py new file mode 100644 index 00000000..7f2485c0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intensities.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200ResponseIntensities(BaseModel): + """ + PostSheepbeef200ResponseIntensities + """ # noqa: E501 + beef_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef including carbon sequestration, in kg-CO2e/kg liveweight", alias="beefIncludingSequestration") + beef_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Beef excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="beefExcludingSequestration") + liveweight_beef_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Liveweight produced in kg", alias="liveweightBeefProducedKg") + wool_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production including carbon sequestration, in kg-CO2e/kg greasy", alias="woolIncludingSequestration") + wool_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Wool production excluding carbon sequestration, in kg-CO2e/kg greasy", alias="woolExcludingSequestration") + sheep_meat_breeding_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sheep meat (breeding herd) including carbon sequestration, in kg-CO2e/kg liveweight", alias="sheepMeatBreedingIncludingSequestration") + sheep_meat_breeding_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sheep meat (breeding herd) excluding carbon sequestration, in kg-CO2e/kg liveweight", alias="sheepMeatBreedingExcludingSequestration") + wool_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Greasy wool produced in kg", alias="woolProducedKg") + sheep_meat_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Sheep meat produced in kg liveweight", alias="sheepMeatProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["beefIncludingSequestration", "beefExcludingSequestration", "liveweightBeefProducedKg", "woolIncludingSequestration", "woolExcludingSequestration", "sheepMeatBreedingIncludingSequestration", "sheepMeatBreedingExcludingSequestration", "woolProducedKg", "sheepMeatProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "beefIncludingSequestration": obj.get("beefIncludingSequestration"), + "beefExcludingSequestration": obj.get("beefExcludingSequestration"), + "liveweightBeefProducedKg": obj.get("liveweightBeefProducedKg"), + "woolIncludingSequestration": obj.get("woolIncludingSequestration"), + "woolExcludingSequestration": obj.get("woolExcludingSequestration"), + "sheepMeatBreedingIncludingSequestration": obj.get("sheepMeatBreedingIncludingSequestration"), + "sheepMeatBreedingExcludingSequestration": obj.get("sheepMeatBreedingExcludingSequestration"), + "woolProducedKg": obj.get("woolProducedKg"), + "sheepMeatProducedKg": obj.get("sheepMeatProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate.py new file mode 100644 index 00000000..09ca1273 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_sheepbeef200_response_intermediate_beef import PostSheepbeef200ResponseIntermediateBeef +from openapi_client.models.post_sheepbeef200_response_intermediate_sheep import PostSheepbeef200ResponseIntermediateSheep +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200ResponseIntermediate(BaseModel): + """ + Intermediate emission output breakdown just for sheep and beef livestock. These combine to make up the total emission output for each scope + """ # noqa: E501 + beef: PostSheepbeef200ResponseIntermediateBeef + sheep: PostSheepbeef200ResponseIntermediateSheep + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["beef", "sheep"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of beef + if self.beef: + _dict['beef'] = self.beef.to_dict() + # override the default output from pydantic by calling `to_dict()` of sheep + if self.sheep: + _dict['sheep'] = self.sheep.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "beef": PostSheepbeef200ResponseIntermediateBeef.from_dict(obj["beef"]) if obj.get("beef") is not None else None, + "sheep": PostSheepbeef200ResponseIntermediateSheep.from_dict(obj["sheep"]) if obj.get("sheep") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_beef.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_beef.py new file mode 100644 index 00000000..7798e4e4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_beef.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_intermediate_inner_intensities import PostBeef200ResponseIntermediateInnerIntensities +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200ResponseIntermediateBeef(BaseModel): + """ + Emission output breakdown just for beef livestock + """ # noqa: E501 + scope1: PostBeef200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + net: PostAquaculture200ResponseNet + intensities: PostBeef200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediateBeef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediateBeef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBeef200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostBeef200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_sheep.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_sheep.py new file mode 100644 index 00000000..95e3694d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_intermediate_sheep.py @@ -0,0 +1,131 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_beef200_response_scope1 import PostBeef200ResponseScope1 +from openapi_client.models.post_beef200_response_scope3 import PostBeef200ResponseScope3 +from openapi_client.models.post_sheep200_response_intermediate_inner_intensities import PostSheep200ResponseIntermediateInnerIntensities +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200ResponseIntermediateSheep(BaseModel): + """ + Emission output breakdown just for sheep livestock + """ # noqa: E501 + scope1: PostBeef200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostBeef200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + net: PostAquaculture200ResponseNet + intensities: PostSheep200ResponseIntermediateInnerIntensities + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediateSheep from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseIntermediateSheep from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostBeef200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostBeef200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostSheep200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_net.py new file mode 100644 index 00000000..07d2ab2e --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef200_response_net.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeef200ResponseNet(BaseModel): + """ + PostSheepbeef200ResponseNet + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] = Field(description="Total net emissions of this activity, in tonnes-CO2e/year") + beef: Union[StrictFloat, StrictInt] = Field(description="Net emissions of beef, in tonnes-CO2e/year") + sheep: Union[StrictFloat, StrictInt] = Field(description="Net emissions of sheep, in tonnes-CO2e/year") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "beef", "sheep"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeef200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "beef": obj.get("beef"), + "sheep": obj.get("sheep") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request.py new file mode 100644 index 00000000..1587c41f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request.py @@ -0,0 +1,152 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_beef_request_beef_inner import PostBeefRequestBeefInner +from openapi_client.models.post_beef_request_burning_inner_burning import PostBeefRequestBurningInnerBurning +from openapi_client.models.post_sheep_request_sheep_inner import PostSheepRequestSheepInner +from openapi_client.models.post_sheepbeef_request_vegetation_inner import PostSheepbeefRequestVegetationInner +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeefRequest(BaseModel): + """ + Input data required for the `sheepbeef` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + north_of_tropic_of_capricorn: StrictBool = Field(description="Is this farm north of the Tropic of Capricorn. Note: this is currently approximately -23.43621 degrees latitude", alias="northOfTropicOfCapricorn") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall to drain through the soil profile. Note: this is typically above 600mm", alias="rainfallAbove600") + beef: List[PostBeefRequestBeefInner] + sheep: List[PostSheepRequestSheepInner] + burning: List[PostBeefRequestBurningInnerBurning] + vegetation: List[PostSheepbeefRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "northOfTropicOfCapricorn", "rainfallAbove600", "beef", "sheep", "burning", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeefRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in beef (list) + _items = [] + if self.beef: + for _item_beef in self.beef: + if _item_beef: + _items.append(_item_beef.to_dict()) + _dict['beef'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in sheep (list) + _items = [] + if self.sheep: + for _item_sheep in self.sheep: + if _item_sheep: + _items.append(_item_sheep.to_dict()) + _dict['sheep'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in burning (list) + _items = [] + if self.burning: + for _item_burning in self.burning: + if _item_burning: + _items.append(_item_burning.to_dict()) + _dict['burning'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeefRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "northOfTropicOfCapricorn": obj.get("northOfTropicOfCapricorn"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "beef": [PostBeefRequestBeefInner.from_dict(_item) for _item in obj["beef"]] if obj.get("beef") is not None else None, + "sheep": [PostSheepRequestSheepInner.from_dict(_item) for _item in obj["sheep"]] if obj.get("sheep") is not None else None, + "burning": [PostBeefRequestBurningInnerBurning.from_dict(_item) for _item in obj["burning"]] if obj.get("burning") is not None else None, + "vegetation": [PostSheepbeefRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request_vegetation_inner.py new file mode 100644 index 00000000..03b90990 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sheepbeef_request_vegetation_inner.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostSheepbeefRequestVegetationInner(BaseModel): + """ + Non-productive vegetation inputs along with allocations to sheep and beef + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + beef_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to beef", alias="beefProportion") + sheep_proportion: List[Union[StrictFloat, StrictInt]] = Field(description="The proportion of the sequestration that is allocated to sheep", alias="sheepProportion") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "beefProportion", "sheepProportion"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSheepbeefRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSheepbeefRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "beefProportion": obj.get("beefProportion"), + "sheepProportion": obj.get("sheepProportion") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response.py new file mode 100644 index 00000000..efdf1f4b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_net import PostCotton200ResponseNet +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_sugar200_response_intermediate_inner import PostSugar200ResponseIntermediateInner +from openapi_client.models.post_sugar200_response_intermediate_inner_intensities import PostSugar200ResponseIntermediateInnerIntensities +from typing import Optional, Set +from typing_extensions import Self + +class PostSugar200Response(BaseModel): + """ + Emissions calculation output for the `sugar` calculator + """ # noqa: E501 + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostSugar200ResponseIntermediateInner] + net: PostCotton200ResponseNet + intensities: List[PostSugar200ResponseIntermediateInnerIntensities] = Field(description="Emissions intensity for each crop (in order), in t-CO2e/t crop") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSugar200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSugar200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostSugar200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostCotton200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostSugar200ResponseIntermediateInnerIntensities.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner.py new file mode 100644 index 00000000..98080d11 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_cotton200_response_scope1 import PostCotton200ResponseScope1 +from openapi_client.models.post_cotton200_response_scope3 import PostCotton200ResponseScope3 +from openapi_client.models.post_sugar200_response_intermediate_inner_intensities import PostSugar200ResponseIntermediateInnerIntensities +from typing import Optional, Set +from typing_extensions import Self + +class PostSugar200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Sugar calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostCotton200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostCotton200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostSugar200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSugar200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSugar200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostCotton200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostCotton200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostSugar200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..a793a55f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sugar200_response_intermediate_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSugar200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostSugar200ResponseIntermediateInnerIntensities + """ # noqa: E501 + sugar_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sugar emissions intensity excluding sequestration, in kg-CO2e/kg sugar", alias="sugarExcludingSequestration") + sugar_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Sugar emissions intensity including sequestration, in kg-CO2e/kg sugar", alias="sugarIncludingSequestration") + sugar_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Sugar produced in kg", alias="sugarProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["sugarExcludingSequestration", "sugarIncludingSequestration", "sugarProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSugar200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSugar200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "sugarExcludingSequestration": obj.get("sugarExcludingSequestration"), + "sugarIncludingSequestration": obj.get("sugarIncludingSequestration"), + "sugarProducedKg": obj.get("sugarProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sugar_request.py b/examples/python-api-client/api-client/openapi_client/models/post_sugar_request.py new file mode 100644 index 00000000..530d00f0 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sugar_request.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from openapi_client.models.post_cotton_request_vegetation_inner import PostCottonRequestVegetationInner +from openapi_client.models.post_sugar_request_crops_inner import PostSugarRequestCropsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostSugarRequest(BaseModel): + """ + Input data required for the `sugar` calculator + """ # noqa: E501 + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + crops: List[PostSugarRequestCropsInner] + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + vegetation: List[PostCottonRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["state", "crops", "electricityRenewable", "electricityUse", "vegetation"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSugarRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in crops (list) + _items = [] + if self.crops: + for _item_crops in self.crops: + if _item_crops: + _items.append(_item_crops.to_dict()) + _dict['crops'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSugarRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "state": obj.get("state"), + "crops": [PostSugarRequestCropsInner.from_dict(_item) for _item in obj["crops"]] if obj.get("crops") is not None else None, + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "vegetation": [PostCottonRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_sugar_request_crops_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_sugar_request_crops_inner.py new file mode 100644 index 00000000..52419ef9 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_sugar_request_crops_inner.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostSugarRequestCropsInner(BaseModel): + """ + PostSugarRequestCropsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + production_system: StrictStr = Field(description="Production system of this crop", alias="productionSystem") + average_cane_yield: Union[StrictFloat, StrictInt] = Field(description="Average cane/crop yield, in t/ha (tonnes per hectare)", alias="averageCaneYield") + percent_milled_cane_yield: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Percentage of cane yield that becomes milled sugar, from 0 to 1", alias="percentMilledCaneYield") + area_sown: Union[StrictFloat, StrictInt] = Field(description="Area sown, in ha (hectares)", alias="areaSown") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm", alias="rainfallAbove600") + fraction_of_annual_crop_burnt: Union[StrictFloat, StrictInt] = Field(description="Fraction of annual production of crop that is burnt, from 0 to 1", alias="fractionOfAnnualCropBurnt") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_allocation: Union[StrictFloat, StrictInt] = Field(description="Percentage of electricity use to allocate to this crop, from 0 to 1", alias="electricityAllocation") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + diesel_use: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)", alias="dieselUse") + petrol_use: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)", alias="petrolUse") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "productionSystem", "averageCaneYield", "percentMilledCaneYield", "areaSown", "nonUreaNitrogen", "ureaApplication", "ureaAmmoniumNitrate", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "rainfallAbove600", "fractionOfAnnualCropBurnt", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityAllocation", "limestone", "limestoneFraction", "dieselUse", "petrolUse", "lpg"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('production_system') + def production_system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Non-irrigated crop', 'Irrigated crop', 'Sugar cane', 'Cotton', 'Horticulture']): + raise ValueError("must be one of enum values ('Non-irrigated crop', 'Irrigated crop', 'Sugar cane', 'Cotton', 'Horticulture')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostSugarRequestCropsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostSugarRequestCropsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "productionSystem": obj.get("productionSystem"), + "averageCaneYield": obj.get("averageCaneYield"), + "percentMilledCaneYield": obj.get("percentMilledCaneYield"), + "areaSown": obj.get("areaSown"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen"), + "ureaApplication": obj.get("ureaApplication"), + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate"), + "phosphorusApplication": obj.get("phosphorusApplication"), + "potassiumApplication": obj.get("potassiumApplication"), + "sulfurApplication": obj.get("sulfurApplication"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "fractionOfAnnualCropBurnt": obj.get("fractionOfAnnualCropBurnt"), + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityAllocation": obj.get("electricityAllocation"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "dieselUse": obj.get("dieselUse"), + "petrolUse": obj.get("petrolUse"), + "lpg": obj.get("lpg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response.py new file mode 100644 index 00000000..b2c5efc5 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_vineyard200_response_intermediate_inner import PostVineyard200ResponseIntermediateInner +from openapi_client.models.post_vineyard200_response_intermediate_inner_intensities import PostVineyard200ResponseIntermediateInnerIntensities +from openapi_client.models.post_vineyard200_response_net import PostVineyard200ResponseNet +from openapi_client.models.post_vineyard200_response_scope1 import PostVineyard200ResponseScope1 +from openapi_client.models.post_vineyard200_response_scope3 import PostVineyard200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200Response(BaseModel): + """ + Emissions calculation output for the `vineyard` calculator + """ # noqa: E501 + scope1: PostVineyard200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostVineyard200ResponseScope3 + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostVineyard200ResponseIntermediateInner] + net: PostVineyard200ResponseNet + intensities: List[PostVineyard200ResponseIntermediateInnerIntensities] = Field(description="Emissions intensity for each vineyard (in order), in t-CO2e/t yield") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "carbonSequestration", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostVineyard200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostVineyard200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostVineyard200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostVineyard200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostVineyard200ResponseIntermediateInnerIntensities.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner.py new file mode 100644 index 00000000..dc69fb89 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_vineyard200_response_intermediate_inner_intensities import PostVineyard200ResponseIntermediateInnerIntensities +from openapi_client.models.post_vineyard200_response_scope1 import PostVineyard200ResponseScope1 +from openapi_client.models.post_vineyard200_response_scope3 import PostVineyard200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Vineyard calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostVineyard200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostVineyard200ResponseScope3 + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostVineyard200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostVineyard200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostVineyard200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostVineyard200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..7c3d5bfb --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_intermediate_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostVineyard200ResponseIntermediateInnerIntensities + """ # noqa: E501 + vineyards_excluding_sequestration: Union[StrictFloat, StrictInt] = Field(description="Vineyard emissions intensity excluding sequestration, in kg-CO2e/kg crop", alias="vineyardsExcludingSequestration") + vineyards_including_sequestration: Union[StrictFloat, StrictInt] = Field(description="Vineyard emissions intensity including sequestration, in kg-CO2e/kg crop", alias="vineyardsIncludingSequestration") + crop_produced_kg: Union[StrictFloat, StrictInt] = Field(description="Vineyard crop produced in kg", alias="cropProducedKg") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vineyardsExcludingSequestration", "vineyardsIncludingSequestration", "cropProducedKg"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vineyardsExcludingSequestration": obj.get("vineyardsExcludingSequestration"), + "vineyardsIncludingSequestration": obj.get("vineyardsIncludingSequestration"), + "cropProducedKg": obj.get("cropProducedKg") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_net.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_net.py new file mode 100644 index 00000000..36d6b1d1 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_net.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200ResponseNet(BaseModel): + """ + Net emissions for each vineyard (in order) + """ # noqa: E501 + total: Union[StrictFloat, StrictInt] + vineyards: List[Union[StrictFloat, StrictInt]] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["total", "vineyards"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseNet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseNet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "vineyards": obj.get("vineyards") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope1.py new file mode 100644 index 00000000..30d5a98f --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope1.py @@ -0,0 +1,129 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + lime_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from lime, in tonnes-CO2e", alias="limeCO2") + urea_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from urea, in tonnes-CO2e", alias="ureaCO2") + waste_water_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from wastewater, in tonnes-CO2e", alias="wasteWaterCO2") + composted_solid_waste_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from composted solid waste, in tonnes-CO2e", alias="compostedSolidWasteCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fertiliser_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fertiliser, in tonnes-CO2e", alias="fertiliserN2O") + atmospheric_deposition_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from atmospheric deposition, in tonnes-CO2e", alias="atmosphericDepositionN2O") + crop_residue_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from crop residue, in tonnes-CO2e", alias="cropResidueN2O") + leaching_and_runoff_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from leeching and runoff, in tonnes-CO2e", alias="leachingAndRunoffN2O") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "limeCO2", "ureaCO2", "wasteWaterCO2", "compostedSolidWasteCO2", "fuelCH4", "fertiliserN2O", "atmosphericDepositionN2O", "cropResidueN2O", "leachingAndRunoffN2O", "fuelN2O", "totalCO2", "totalCH4", "totalN2O", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "limeCO2": obj.get("limeCO2"), + "ureaCO2": obj.get("ureaCO2"), + "wasteWaterCO2": obj.get("wasteWaterCO2"), + "compostedSolidWasteCO2": obj.get("compostedSolidWasteCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fertiliserN2O": obj.get("fertiliserN2O"), + "atmosphericDepositionN2O": obj.get("atmosphericDepositionN2O"), + "cropResidueN2O": obj.get("cropResidueN2O"), + "leachingAndRunoffN2O": obj.get("leachingAndRunoffN2O"), + "fuelN2O": obj.get("fuelN2O"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope3.py new file mode 100644 index 00000000..31264f02 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard200_response_scope3.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyard200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fertiliser: Union[StrictFloat, StrictInt] = Field(description="Emissions from fertiliser, in tonnes-CO2e") + herbicide: Union[StrictFloat, StrictInt] = Field(description="Emissions from herbicide, in tonnes-CO2e") + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + lime: Union[StrictFloat, StrictInt] = Field(description="Emissions from lime, in tonnes-CO2e") + commercial_flights: Union[StrictFloat, StrictInt] = Field(description="Emissions from commercial flights, in tonnes-CO2e", alias="commercialFlights") + inbound_freight: Union[StrictFloat, StrictInt] = Field(description="Emissions from inbound freight, in tonnes-CO2e", alias="inboundFreight") + solid_waste_sent_offsite: Union[StrictFloat, StrictInt] = Field(description="Emissions from solid waste sent offsite, in tonnes-CO2e", alias="solidWasteSentOffsite") + outbound_freight: Union[StrictFloat, StrictInt] = Field(description="Emissions from outbound freight, in tonnes-CO2e", alias="outboundFreight") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fertiliser", "herbicide", "electricity", "fuel", "lime", "commercialFlights", "inboundFreight", "solidWasteSentOffsite", "outboundFreight", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyard200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fertiliser": obj.get("fertiliser"), + "herbicide": obj.get("herbicide"), + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "lime": obj.get("lime"), + "commercialFlights": obj.get("commercialFlights"), + "inboundFreight": obj.get("inboundFreight"), + "solidWasteSentOffsite": obj.get("solidWasteSentOffsite"), + "outboundFreight": obj.get("outboundFreight"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request.py new file mode 100644 index 00000000..a4aec75c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_vineyard_request_vegetation_inner import PostVineyardRequestVegetationInner +from openapi_client.models.post_vineyard_request_vineyards_inner import PostVineyardRequestVineyardsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyardRequest(BaseModel): + """ + Input data required for the `vineyard` calculator + """ # noqa: E501 + vineyards: List[PostVineyardRequestVineyardsInner] + vegetation: List[PostVineyardRequestVegetationInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vineyards", "vegetation"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyardRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in vineyards (list) + _items = [] + if self.vineyards: + for _item_vineyards in self.vineyards: + if _item_vineyards: + _items.append(_item_vineyards.to_dict()) + _dict['vineyards'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in vegetation (list) + _items = [] + if self.vegetation: + for _item_vegetation in self.vegetation: + if _item_vegetation: + _items.append(_item_vegetation.to_dict()) + _dict['vegetation'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyardRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vineyards": [PostVineyardRequestVineyardsInner.from_dict(_item) for _item in obj["vineyards"]] if obj.get("vineyards") is not None else None, + "vegetation": [PostVineyardRequestVegetationInner.from_dict(_item) for _item in obj["vegetation"]] if obj.get("vegetation") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vegetation_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vegetation_inner.py new file mode 100644 index 00000000..0d2fb3e2 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vegetation_inner.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_beef_request_vegetation_inner_vegetation import PostBeefRequestVegetationInnerVegetation +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyardRequestVegetationInner(BaseModel): + """ + PostVineyardRequestVegetationInner + """ # noqa: E501 + vegetation: PostBeefRequestVegetationInnerVegetation + allocation_to_vineyards: List[Union[StrictFloat, StrictInt]] = Field(alias="allocationToVineyards") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["vegetation", "allocationToVineyards"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyardRequestVegetationInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of vegetation + if self.vegetation: + _dict['vegetation'] = self.vegetation.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyardRequestVegetationInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "vegetation": PostBeefRequestVegetationInnerVegetation.from_dict(obj["vegetation"]) if obj.get("vegetation") is not None else None, + "allocationToVineyards": obj.get("allocationToVineyards") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vineyards_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vineyards_inner.py new file mode 100644 index 00000000..f977e70b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_vineyard_request_vineyards_inner.py @@ -0,0 +1,195 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_inbound_freight_inner import PostAquacultureRequestEnterprisesInnerInboundFreightInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste +from typing import Optional, Set +from typing_extensions import Self + +class PostVineyardRequestVineyardsInner(BaseModel): + """ + PostVineyardRequestVineyardsInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + rainfall_above600: StrictBool = Field(description="Is there enough rainfall or irrigation to drain through the soil profile, typically above 600mm", alias="rainfallAbove600") + irrigated: StrictBool = Field(description="Is the crop irrigated?") + area_planted: Union[StrictFloat, StrictInt] = Field(description="Area planted, in ha (hectares)", alias="areaPlanted") + average_yield: Union[StrictFloat, StrictInt] = Field(description="Average yield, in t/ha (tonnes per hectare)", alias="averageYield") + non_urea_nitrogen: Union[StrictFloat, StrictInt] = Field(description="Non-urea nitrogen application, in kg N/ha (kilograms of nitrogen per hectare)", alias="nonUreaNitrogen") + phosphorus_application: Union[StrictFloat, StrictInt] = Field(description="Phosphorus application, in kg P/ha (kilograms of phosphorus per hectare)", alias="phosphorusApplication") + potassium_application: Union[StrictFloat, StrictInt] = Field(description="Potassium application, in kg K/ha (kilograms of potassium per hectare)", alias="potassiumApplication") + sulfur_application: Union[StrictFloat, StrictInt] = Field(description="Sulfur application, in kg S/ha (kilograms of sulfur per hectare)", alias="sulfurApplication") + urea_application: Union[StrictFloat, StrictInt] = Field(description="Urea nitrogen application, in kg Urea/ha (kilograms of urea per hectare)", alias="ureaApplication") + urea_ammonium_nitrate: Union[StrictFloat, StrictInt] = Field(description="Urea-Ammonium nitrate application, in kg product/ha (kilograms of product per hectare)", alias="ureaAmmoniumNitrate") + limestone: Union[StrictFloat, StrictInt] = Field(description="Lime applied in tonnes") + limestone_fraction: Union[StrictFloat, StrictInt] = Field(description="Fraction of lime as limestone vs dolomite, between 0 and 1", alias="limestoneFraction") + herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from general herbicide/pesticide use, in kg (kilogram)", alias="herbicideUse") + glyphosate_other_herbicide_use: Union[StrictFloat, StrictInt] = Field(description="Total amount of active ingredients from other herbicide use (Paraquat, Diquat, Glyphosate), in kg (kilogram)", alias="glyphosateOtherHerbicideUse") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + fuel: PostAquacultureRequestEnterprisesInnerFuel + fluid_waste: List[PostAquacultureRequestEnterprisesInnerFluidWasteInner] = Field(description="Amount of fluid waste, in kL (kilolitres)", alias="fluidWaste") + solid_waste: PostAquacultureRequestEnterprisesInnerSolidWaste = Field(alias="solidWaste") + inbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods to the enterprise", alias="inboundFreight") + outbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods from the enterprise", alias="outboundFreight") + total_commercial_flights_km: Union[StrictFloat, StrictInt] = Field(description="Total distance of commercial flights, in km (kilometers)", alias="totalCommercialFlightsKm") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "rainfallAbove600", "irrigated", "areaPlanted", "averageYield", "nonUreaNitrogen", "phosphorusApplication", "potassiumApplication", "sulfurApplication", "ureaApplication", "ureaAmmoniumNitrate", "limestone", "limestoneFraction", "herbicideUse", "glyphosateOtherHerbicideUse", "electricityRenewable", "electricityUse", "electricitySource", "fuel", "fluidWaste", "solidWaste", "inboundFreight", "outboundFreight", "totalCommercialFlightsKm"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostVineyardRequestVineyardsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of fuel + if self.fuel: + _dict['fuel'] = self.fuel.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in fluid_waste (list) + _items = [] + if self.fluid_waste: + for _item_fluid_waste in self.fluid_waste: + if _item_fluid_waste: + _items.append(_item_fluid_waste.to_dict()) + _dict['fluidWaste'] = _items + # override the default output from pydantic by calling `to_dict()` of solid_waste + if self.solid_waste: + _dict['solidWaste'] = self.solid_waste.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in inbound_freight (list) + _items = [] + if self.inbound_freight: + for _item_inbound_freight in self.inbound_freight: + if _item_inbound_freight: + _items.append(_item_inbound_freight.to_dict()) + _dict['inboundFreight'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in outbound_freight (list) + _items = [] + if self.outbound_freight: + for _item_outbound_freight in self.outbound_freight: + if _item_outbound_freight: + _items.append(_item_outbound_freight.to_dict()) + _dict['outboundFreight'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostVineyardRequestVineyardsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "rainfallAbove600": obj.get("rainfallAbove600"), + "irrigated": obj.get("irrigated"), + "areaPlanted": obj.get("areaPlanted"), + "averageYield": obj.get("averageYield"), + "nonUreaNitrogen": obj.get("nonUreaNitrogen"), + "phosphorusApplication": obj.get("phosphorusApplication"), + "potassiumApplication": obj.get("potassiumApplication"), + "sulfurApplication": obj.get("sulfurApplication"), + "ureaApplication": obj.get("ureaApplication"), + "ureaAmmoniumNitrate": obj.get("ureaAmmoniumNitrate"), + "limestone": obj.get("limestone"), + "limestoneFraction": obj.get("limestoneFraction"), + "herbicideUse": obj.get("herbicideUse"), + "glyphosateOtherHerbicideUse": obj.get("glyphosateOtherHerbicideUse"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "electricitySource": obj.get("electricitySource"), + "fuel": PostAquacultureRequestEnterprisesInnerFuel.from_dict(obj["fuel"]) if obj.get("fuel") is not None else None, + "fluidWaste": [PostAquacultureRequestEnterprisesInnerFluidWasteInner.from_dict(_item) for _item in obj["fluidWaste"]] if obj.get("fluidWaste") is not None else None, + "solidWaste": PostAquacultureRequestEnterprisesInnerSolidWaste.from_dict(obj["solidWaste"]) if obj.get("solidWaste") is not None else None, + "inboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["inboundFreight"]] if obj.get("inboundFreight") is not None else None, + "outboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["outboundFreight"]] if obj.get("outboundFreight") is not None else None, + "totalCommercialFlightsKm": obj.get("totalCommercialFlightsKm") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response.py new file mode 100644 index 00000000..c88bdcbd --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response.py @@ -0,0 +1,151 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_carbon_sequestration import PostAquaculture200ResponseCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 +from openapi_client.models.post_wildcatchfishery200_response_intensities import PostWildcatchfishery200ResponseIntensities +from openapi_client.models.post_wildcatchfishery200_response_intermediate_inner import PostWildcatchfishery200ResponseIntermediateInner +from openapi_client.models.post_wildcatchfishery200_response_scope1 import PostWildcatchfishery200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfishery200Response(BaseModel): + """ + Emissions calculation output for the `wildcatchfishery` calculator + """ # noqa: E501 + scope1: PostWildcatchfishery200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostAquaculture200ResponseScope3 + purchased_offsets: PostAquaculture200ResponsePurchasedOffsets = Field(alias="purchasedOffsets") + net: PostAquaculture200ResponseNet + intensities: PostWildcatchfishery200ResponseIntensities + carbon_sequestration: PostAquaculture200ResponseCarbonSequestration = Field(alias="carbonSequestration") + intermediate: List[PostWildcatchfishery200ResponseIntermediateInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "purchasedOffsets", "net", "intensities", "carbonSequestration", "intermediate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchased_offsets + if self.purchased_offsets: + _dict['purchasedOffsets'] = self.purchased_offsets.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostWildcatchfishery200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostAquaculture200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "purchasedOffsets": PostAquaculture200ResponsePurchasedOffsets.from_dict(obj["purchasedOffsets"]) if obj.get("purchasedOffsets") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": PostWildcatchfishery200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "carbonSequestration": PostAquaculture200ResponseCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None, + "intermediate": [PostWildcatchfishery200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intensities.py new file mode 100644 index 00000000..6c98b7e3 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfishery200ResponseIntensities(BaseModel): + """ + PostWildcatchfishery200ResponseIntensities + """ # noqa: E501 + total_harvest_weight_kg: Union[StrictFloat, StrictInt] = Field(description="Total harvest weight in kg", alias="totalHarvestWeightKg") + wild_catch_fishery_excluding_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Wild catch fishery emissions intensity excluding sequestration, in kg-CO2e/kg harvest weight", alias="wildCatchFisheryExcludingCarbonOffsets") + wild_catch_fishery_including_carbon_offsets: Union[StrictFloat, StrictInt] = Field(description="Wild catch fishery emissions intensity including sequestration, in kg-CO2e/kg harvest weight", alias="wildCatchFisheryIncludingCarbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["totalHarvestWeightKg", "wildCatchFisheryExcludingCarbonOffsets", "wildCatchFisheryIncludingCarbonOffsets"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "totalHarvestWeightKg": obj.get("totalHarvestWeightKg"), + "wildCatchFisheryExcludingCarbonOffsets": obj.get("wildCatchFisheryExcludingCarbonOffsets"), + "wildCatchFisheryIncludingCarbonOffsets": obj.get("wildCatchFisheryIncludingCarbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intermediate_inner.py new file mode 100644 index 00000000..0aecf07a --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_intermediate_inner.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_intermediate_inner_carbon_sequestration import PostAquaculture200ResponseIntermediateInnerCarbonSequestration +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_aquaculture200_response_scope3 import PostAquaculture200ResponseScope3 +from openapi_client.models.post_wildcatchfishery200_response_intensities import PostWildcatchfishery200ResponseIntensities +from openapi_client.models.post_wildcatchfishery200_response_scope1 import PostWildcatchfishery200ResponseScope1 +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfishery200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the `wildcatchfishery` calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostWildcatchfishery200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostAquaculture200ResponseScope3 + intensities: PostWildcatchfishery200ResponseIntensities + net: PostAquaculture200ResponseNet + carbon_sequestration: PostAquaculture200ResponseIntermediateInnerCarbonSequestration = Field(alias="carbonSequestration") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "intensities", "net", "carbonSequestration"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of carbon_sequestration + if self.carbon_sequestration: + _dict['carbonSequestration'] = self.carbon_sequestration.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostWildcatchfishery200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostAquaculture200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "intensities": PostWildcatchfishery200ResponseIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "carbonSequestration": PostAquaculture200ResponseIntermediateInnerCarbonSequestration.from_dict(obj["carbonSequestration"]) if obj.get("carbonSequestration") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_scope1.py new file mode 100644 index 00000000..29419d0c --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery200_response_scope1.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfishery200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + waste_water_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from wastewater, in tonnes-CO2e", alias="wasteWaterCO2") + composted_solid_waste_co2: Union[StrictFloat, StrictInt] = Field(description="Emissions from composted solid waste, in tonnes-CO2e", alias="compostedSolidWasteCO2") + hfcs_refrigerant_leakage: Union[StrictFloat, StrictInt] = Field(description="Emissions from refrigerant leakage, in tonnes-HFCs", alias="hfcsRefrigerantLeakage") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total_hfcs: Union[StrictFloat, StrictInt] = Field(description="Total HFCs scope 1 emissions, in tonnes-CO2e", alias="totalHFCs") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "wasteWaterCO2", "compostedSolidWasteCO2", "hfcsRefrigerantLeakage", "totalCO2", "totalCH4", "totalN2O", "totalHFCs", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfishery200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "wasteWaterCO2": obj.get("wasteWaterCO2"), + "compostedSolidWasteCO2": obj.get("compostedSolidWasteCO2"), + "hfcsRefrigerantLeakage": obj.get("hfcsRefrigerantLeakage"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "totalHFCs": obj.get("totalHFCs"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request.py new file mode 100644 index 00000000..d289f6ee --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner import PostWildcatchfisheryRequestEnterprisesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfisheryRequest(BaseModel): + """ + Input data required for the `wildcatchfishery` calculator + """ # noqa: E501 + enterprises: List[PostWildcatchfisheryRequestEnterprisesInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["enterprises"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in enterprises (list) + _items = [] + if self.enterprises: + for _item_enterprises in self.enterprises: + if _item_enterprises: + _items.append(_item_enterprises.to_dict()) + _dict['enterprises'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "enterprises": [PostWildcatchfisheryRequestEnterprisesInner.from_dict(_item) for _item in obj["enterprises"]] if obj.get("enterprises") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner.py new file mode 100644 index 00000000..84e1f96b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner.py @@ -0,0 +1,210 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_aquaculture_request_enterprises_inner_custom_bait_inner import PostAquacultureRequestEnterprisesInnerCustomBaitInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fluid_waste_inner import PostAquacultureRequestEnterprisesInnerFluidWasteInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_fuel import PostAquacultureRequestEnterprisesInnerFuel +from openapi_client.models.post_aquaculture_request_enterprises_inner_inbound_freight_inner import PostAquacultureRequestEnterprisesInnerInboundFreightInner +from openapi_client.models.post_aquaculture_request_enterprises_inner_solid_waste import PostAquacultureRequestEnterprisesInnerSolidWaste +from openapi_client.models.post_horticulture_request_crops_inner_refrigerants_inner import PostHorticultureRequestCropsInnerRefrigerantsInner +from openapi_client.models.post_wildcatchfishery_request_enterprises_inner_bait_inner import PostWildcatchfisheryRequestEnterprisesInnerBaitInner +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfisheryRequestEnterprisesInner(BaseModel): + """ + Input data required for a single wild catch fishery enterprise + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + production_system: StrictStr = Field(description="Production system of the wild catch fishery enterprise", alias="productionSystem") + total_harvest_kg: Union[StrictFloat, StrictInt] = Field(description="Total harvest in kg", alias="totalHarvestKg") + refrigerants: List[PostHorticultureRequestCropsInnerRefrigerantsInner] = Field(description="Refrigerant type") + bait: List[PostWildcatchfisheryRequestEnterprisesInnerBaitInner] = Field(description="Bait purchases") + custom_bait: List[PostAquacultureRequestEnterprisesInnerCustomBaitInner] = Field(description="Custom bait purchases", alias="customBait") + inbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods to the enterprise", alias="inboundFreight") + outbound_freight: List[PostAquacultureRequestEnterprisesInnerInboundFreightInner] = Field(description="Services used to transport goods from the enterprise", alias="outboundFreight") + total_commercial_flights_km: Union[StrictFloat, StrictInt] = Field(description="Total distance of commercial flights, in km (kilometers)", alias="totalCommercialFlightsKm") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + fuel: PostAquacultureRequestEnterprisesInnerFuel + fluid_waste: List[PostAquacultureRequestEnterprisesInnerFluidWasteInner] = Field(description="Amount of fluid waste, in kL (kilolitres)", alias="fluidWaste") + solid_waste: PostAquacultureRequestEnterprisesInnerSolidWaste = Field(alias="solidWaste") + carbon_offsets: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0)", alias="carbonOffsets") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "productionSystem", "totalHarvestKg", "refrigerants", "bait", "customBait", "inboundFreight", "outboundFreight", "totalCommercialFlightsKm", "electricityRenewable", "electricityUse", "electricitySource", "fuel", "fluidWaste", "solidWaste", "carbonOffsets"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('production_system') + def production_system_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Abalone', 'Crab Fishing', 'Demersal Trawl', 'Gillnet', 'Handline', 'Lobster Pot', 'Longline', 'Northern Fish Trap', 'Northern Prawn trawl', 'Otter Board Trawl', 'Prawn trawl Australian average', 'Purse seine', 'Southern Ocean Longline']): + raise ValueError("must be one of enum values ('Abalone', 'Crab Fishing', 'Demersal Trawl', 'Gillnet', 'Handline', 'Lobster Pot', 'Longline', 'Northern Fish Trap', 'Northern Prawn trawl', 'Otter Board Trawl', 'Prawn trawl Australian average', 'Purse seine', 'Southern Ocean Longline')") + return value + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequestEnterprisesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in refrigerants (list) + _items = [] + if self.refrigerants: + for _item_refrigerants in self.refrigerants: + if _item_refrigerants: + _items.append(_item_refrigerants.to_dict()) + _dict['refrigerants'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bait (list) + _items = [] + if self.bait: + for _item_bait in self.bait: + if _item_bait: + _items.append(_item_bait.to_dict()) + _dict['bait'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in custom_bait (list) + _items = [] + if self.custom_bait: + for _item_custom_bait in self.custom_bait: + if _item_custom_bait: + _items.append(_item_custom_bait.to_dict()) + _dict['customBait'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in inbound_freight (list) + _items = [] + if self.inbound_freight: + for _item_inbound_freight in self.inbound_freight: + if _item_inbound_freight: + _items.append(_item_inbound_freight.to_dict()) + _dict['inboundFreight'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in outbound_freight (list) + _items = [] + if self.outbound_freight: + for _item_outbound_freight in self.outbound_freight: + if _item_outbound_freight: + _items.append(_item_outbound_freight.to_dict()) + _dict['outboundFreight'] = _items + # override the default output from pydantic by calling `to_dict()` of fuel + if self.fuel: + _dict['fuel'] = self.fuel.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in fluid_waste (list) + _items = [] + if self.fluid_waste: + for _item_fluid_waste in self.fluid_waste: + if _item_fluid_waste: + _items.append(_item_fluid_waste.to_dict()) + _dict['fluidWaste'] = _items + # override the default output from pydantic by calling `to_dict()` of solid_waste + if self.solid_waste: + _dict['solidWaste'] = self.solid_waste.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequestEnterprisesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "productionSystem": obj.get("productionSystem"), + "totalHarvestKg": obj.get("totalHarvestKg"), + "refrigerants": [PostHorticultureRequestCropsInnerRefrigerantsInner.from_dict(_item) for _item in obj["refrigerants"]] if obj.get("refrigerants") is not None else None, + "bait": [PostWildcatchfisheryRequestEnterprisesInnerBaitInner.from_dict(_item) for _item in obj["bait"]] if obj.get("bait") is not None else None, + "customBait": [PostAquacultureRequestEnterprisesInnerCustomBaitInner.from_dict(_item) for _item in obj["customBait"]] if obj.get("customBait") is not None else None, + "inboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["inboundFreight"]] if obj.get("inboundFreight") is not None else None, + "outboundFreight": [PostAquacultureRequestEnterprisesInnerInboundFreightInner.from_dict(_item) for _item in obj["outboundFreight"]] if obj.get("outboundFreight") is not None else None, + "totalCommercialFlightsKm": obj.get("totalCommercialFlightsKm"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "electricitySource": obj.get("electricitySource"), + "fuel": PostAquacultureRequestEnterprisesInnerFuel.from_dict(obj["fuel"]) if obj.get("fuel") is not None else None, + "fluidWaste": [PostAquacultureRequestEnterprisesInnerFluidWasteInner.from_dict(_item) for _item in obj["fluidWaste"]] if obj.get("fluidWaste") is not None else None, + "solidWaste": PostAquacultureRequestEnterprisesInnerSolidWaste.from_dict(obj["solidWaste"]) if obj.get("solidWaste") is not None else None, + "carbonOffsets": obj.get("carbonOffsets") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner_bait_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner_bait_inner.py new file mode 100644 index 00000000..e2b0b7fe --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildcatchfishery_request_enterprises_inner_bait_inner.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostWildcatchfisheryRequestEnterprisesInnerBaitInner(BaseModel): + """ + PostWildcatchfisheryRequestEnterprisesInnerBaitInner + """ # noqa: E501 + type: StrictStr = Field(description="Bait product type") + purchased_tonnes: Union[StrictFloat, StrictInt] = Field(description="Purchased product in tonnes", alias="purchasedTonnes") + additional_ingredients: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Additional ingredient fraction, from 0 to 1", alias="additionalIngredients") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of additional ingredients, in kg CO2e/kg bait (default 0)", alias="emissionsIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "purchasedTonnes", "additionalIngredients", "emissionsIntensity"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Fish Frames', 'Fish Heads', 'Sardines', 'Squid', 'Whole Fish']): + raise ValueError("must be one of enum values ('Fish Frames', 'Fish Heads', 'Sardines', 'Squid', 'Whole Fish')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequestEnterprisesInnerBaitInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildcatchfisheryRequestEnterprisesInnerBaitInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "purchasedTonnes": obj.get("purchasedTonnes"), + "additionalIngredients": obj.get("additionalIngredients"), + "emissionsIntensity": obj.get("emissionsIntensity") if obj.get("emissionsIntensity") is not None else 0 + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response.py new file mode 100644 index 00000000..1727a97d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner import PostWildseafisheries200ResponseIntermediateInner +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner_intensities import PostWildseafisheries200ResponseIntermediateInnerIntensities +from openapi_client.models.post_wildseafisheries200_response_scope1 import PostWildseafisheries200ResponseScope1 +from openapi_client.models.post_wildseafisheries200_response_scope3 import PostWildseafisheries200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheries200Response(BaseModel): + """ + Emissions calculation output for the `wildseafisheries` calculator + """ # noqa: E501 + scope1: PostWildseafisheries200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostWildseafisheries200ResponseScope3 + purchased_offsets: PostAquaculture200ResponsePurchasedOffsets = Field(alias="purchasedOffsets") + intermediate: List[PostWildseafisheries200ResponseIntermediateInner] + net: PostAquaculture200ResponseNet + intensities: List[PostWildseafisheries200ResponseIntermediateInnerIntensities] = Field(description="Emissions intensity for each enterprise (in order), in t-CO2e/t product caught") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["scope1", "scope2", "scope3", "purchasedOffsets", "intermediate", "net", "intensities"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheries200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchased_offsets + if self.purchased_offsets: + _dict['purchasedOffsets'] = self.purchased_offsets.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intermediate (list) + _items = [] + if self.intermediate: + for _item_intermediate in self.intermediate: + if _item_intermediate: + _items.append(_item_intermediate.to_dict()) + _dict['intermediate'] = _items + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in intensities (list) + _items = [] + if self.intensities: + for _item_intensities in self.intensities: + if _item_intensities: + _items.append(_item_intensities.to_dict()) + _dict['intensities'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheries200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "scope1": PostWildseafisheries200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostWildseafisheries200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "purchasedOffsets": PostAquaculture200ResponsePurchasedOffsets.from_dict(obj["purchasedOffsets"]) if obj.get("purchasedOffsets") is not None else None, + "intermediate": [PostWildseafisheries200ResponseIntermediateInner.from_dict(_item) for _item in obj["intermediate"]] if obj.get("intermediate") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None, + "intensities": [PostWildseafisheries200ResponseIntermediateInnerIntensities.from_dict(_item) for _item in obj["intensities"]] if obj.get("intensities") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner.py new file mode 100644 index 00000000..a543037d --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.post_aquaculture200_response_net import PostAquaculture200ResponseNet +from openapi_client.models.post_aquaculture200_response_purchased_offsets import PostAquaculture200ResponsePurchasedOffsets +from openapi_client.models.post_aquaculture200_response_scope2 import PostAquaculture200ResponseScope2 +from openapi_client.models.post_wildseafisheries200_response_intermediate_inner_intensities import PostWildseafisheries200ResponseIntermediateInnerIntensities +from openapi_client.models.post_wildseafisheries200_response_scope1 import PostWildseafisheries200ResponseScope1 +from openapi_client.models.post_wildseafisheries200_response_scope3 import PostWildseafisheries200ResponseScope3 +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheries200ResponseIntermediateInner(BaseModel): + """ + Intermediate emissions calculation output for the Wild Sea Fisheries calculator + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for this activity") + scope1: PostWildseafisheries200ResponseScope1 + scope2: PostAquaculture200ResponseScope2 + scope3: PostWildseafisheries200ResponseScope3 + purchased_offsets: PostAquaculture200ResponsePurchasedOffsets = Field(alias="purchasedOffsets") + carbon_sequestration: Union[StrictFloat, StrictInt] = Field(description="Carbon sequestration, in tonnes-CO2e", alias="carbonSequestration") + intensities: PostWildseafisheries200ResponseIntermediateInnerIntensities + net: PostAquaculture200ResponseNet + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "scope1", "scope2", "scope3", "purchasedOffsets", "carbonSequestration", "intensities", "net"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseIntermediateInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of scope1 + if self.scope1: + _dict['scope1'] = self.scope1.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope2 + if self.scope2: + _dict['scope2'] = self.scope2.to_dict() + # override the default output from pydantic by calling `to_dict()` of scope3 + if self.scope3: + _dict['scope3'] = self.scope3.to_dict() + # override the default output from pydantic by calling `to_dict()` of purchased_offsets + if self.purchased_offsets: + _dict['purchasedOffsets'] = self.purchased_offsets.to_dict() + # override the default output from pydantic by calling `to_dict()` of intensities + if self.intensities: + _dict['intensities'] = self.intensities.to_dict() + # override the default output from pydantic by calling `to_dict()` of net + if self.net: + _dict['net'] = self.net.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseIntermediateInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "scope1": PostWildseafisheries200ResponseScope1.from_dict(obj["scope1"]) if obj.get("scope1") is not None else None, + "scope2": PostAquaculture200ResponseScope2.from_dict(obj["scope2"]) if obj.get("scope2") is not None else None, + "scope3": PostWildseafisheries200ResponseScope3.from_dict(obj["scope3"]) if obj.get("scope3") is not None else None, + "purchasedOffsets": PostAquaculture200ResponsePurchasedOffsets.from_dict(obj["purchasedOffsets"]) if obj.get("purchasedOffsets") is not None else None, + "carbonSequestration": obj.get("carbonSequestration"), + "intensities": PostWildseafisheries200ResponseIntermediateInnerIntensities.from_dict(obj["intensities"]) if obj.get("intensities") is not None else None, + "net": PostAquaculture200ResponseNet.from_dict(obj["net"]) if obj.get("net") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner_intensities.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner_intensities.py new file mode 100644 index 00000000..f59bf784 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_intermediate_inner_intensities.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheries200ResponseIntermediateInnerIntensities(BaseModel): + """ + PostWildseafisheries200ResponseIntermediateInnerIntensities + """ # noqa: E501 + intensity_excluding_carbon_offset: Union[StrictFloat, StrictInt] = Field(description="Wild sea fisheries emissions intensity excluding carbon offsets, in kg-CO2e/kg", alias="intensityExcludingCarbonOffset") + intensity_including_carbon_offset: Union[StrictFloat, StrictInt] = Field(description="Wild sea fisheries emissions intensity including carbon offsets, in kg-CO2e/kg", alias="intensityIncludingCarbonOffset") + total_harvest_weight_tonnes: Union[StrictFloat, StrictInt] = Field(description="Total harvest weight in tonnes", alias="totalHarvestWeightTonnes") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["intensityExcludingCarbonOffset", "intensityIncludingCarbonOffset", "totalHarvestWeightTonnes"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseIntermediateInnerIntensities from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseIntermediateInnerIntensities from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "intensityExcludingCarbonOffset": obj.get("intensityExcludingCarbonOffset"), + "intensityIncludingCarbonOffset": obj.get("intensityIncludingCarbonOffset"), + "totalHarvestWeightTonnes": obj.get("totalHarvestWeightTonnes") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope1.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope1.py new file mode 100644 index 00000000..5b493f9b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope1.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheries200ResponseScope1(BaseModel): + """ + Scope 1 greenhouse gas emissions are the emissions released to the atmosphere as a direct result of an activity, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + fuel_co2: Union[StrictFloat, StrictInt] = Field(description="CO2 emissions from fuel use, in tonnes-CO2e", alias="fuelCO2") + fuel_ch4: Union[StrictFloat, StrictInt] = Field(description="CH4 emissions from fuel use, in tonnes-CO2e", alias="fuelCH4") + fuel_n2_o: Union[StrictFloat, StrictInt] = Field(description="N2O emissions from fuel use, in tonnes-CO2e", alias="fuelN2O") + hfcs_refrigerant_leakage: Union[StrictFloat, StrictInt] = Field(description="Emissions from refrigerant leakage, in tonnes-HFCs", alias="hfcsRefrigerantLeakage") + total_co2: Union[StrictFloat, StrictInt] = Field(description="Total CO2 scope 1 emissions, in tonnes-CO2e", alias="totalCO2") + total_ch4: Union[StrictFloat, StrictInt] = Field(description="Total CH4 scope 1 emissions, in tonnes-CO2e", alias="totalCH4") + total_n2_o: Union[StrictFloat, StrictInt] = Field(description="Total N2O scope 1 emissions, in tonnes-CO2e", alias="totalN2O") + total_hfcs: Union[StrictFloat, StrictInt] = Field(description="Total HFCs scope 1 emissions, in tonnes-CO2e", alias="totalHFCs") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 1 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["fuelCO2", "fuelCH4", "fuelN2O", "hfcsRefrigerantLeakage", "totalCO2", "totalCH4", "totalN2O", "totalHFCs", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseScope1 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseScope1 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fuelCO2": obj.get("fuelCO2"), + "fuelCH4": obj.get("fuelCH4"), + "fuelN2O": obj.get("fuelN2O"), + "hfcsRefrigerantLeakage": obj.get("hfcsRefrigerantLeakage"), + "totalCO2": obj.get("totalCO2"), + "totalCH4": obj.get("totalCH4"), + "totalN2O": obj.get("totalN2O"), + "totalHFCs": obj.get("totalHFCs"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope3.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope3.py new file mode 100644 index 00000000..dce98203 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries200_response_scope3.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheries200ResponseScope3(BaseModel): + """ + Scope 3 emissions are indirect greenhouse gas emissions other than scope 2 emissions that are generated in the wider economy, in tonnes-CO2e (tonnes of carbon dioxide equivalent) + """ # noqa: E501 + electricity: Union[StrictFloat, StrictInt] = Field(description="Emissions from electricity, in tonnes-CO2e") + fuel: Union[StrictFloat, StrictInt] = Field(description="Emissions from fuel, in tonnes-CO2e") + bait: Union[StrictFloat, StrictInt] = Field(description="Emissions from purchased bait, in tonnes-CO2e") + total: Union[StrictFloat, StrictInt] = Field(description="Total scope 3 emissions, in tonnes-CO2e") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["electricity", "fuel", "bait", "total"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseScope3 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheries200ResponseScope3 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "electricity": obj.get("electricity"), + "fuel": obj.get("fuel"), + "bait": obj.get("bait"), + "total": obj.get("total") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request.py new file mode 100644 index 00000000..afa1c8b4 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List +from openapi_client.models.post_wildseafisheries_request_enterprises_inner import PostWildseafisheriesRequestEnterprisesInner +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequest(BaseModel): + """ + Input data required for the `wildseafisheries` calculator + """ # noqa: E501 + enterprises: List[PostWildseafisheriesRequestEnterprisesInner] + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["enterprises"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in enterprises (list) + _items = [] + if self.enterprises: + for _item_enterprises in self.enterprises: + if _item_enterprises: + _items.append(_item_enterprises.to_dict()) + _dict['enterprises'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "enterprises": [PostWildseafisheriesRequestEnterprisesInner.from_dict(_item) for _item in obj["enterprises"]] if obj.get("enterprises") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner.py new file mode 100644 index 00000000..b3ef8317 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner.py @@ -0,0 +1,184 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_bait_inner import PostWildseafisheriesRequestEnterprisesInnerBaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_custombait_inner import PostWildseafisheriesRequestEnterprisesInnerCustombaitInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_flights_inner import PostWildseafisheriesRequestEnterprisesInnerFlightsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_refrigerants_inner import PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner +from openapi_client.models.post_wildseafisheries_request_enterprises_inner_transports_inner import PostWildseafisheriesRequestEnterprisesInnerTransportsInner +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInner + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="Unique identifier for this activity") + state: StrictStr = Field(description="What state the location is in. Note: Western Australia is split up into two regions, `wa_nw` is North-West Western Australia, `wa_sw` is South-West Western Australia") + electricity_source: StrictStr = Field(description="Source of electricity", alias="electricitySource") + electricity_renewable: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Percent of total electricity usage that is drawn from renewable sources, between 0 and 1. Unused if `electricitySource` is `Renewable`", alias="electricityRenewable") + electricity_use: Union[StrictFloat, StrictInt] = Field(description="Electricity use in KWh (kilowatt hours)", alias="electricityUse") + total_whole_weight_caught: Union[StrictFloat, StrictInt] = Field(description="Total whole weight caught in kg", alias="totalWholeWeightCaught") + diesel: Union[StrictFloat, StrictInt] = Field(description="Diesel usage in L (litres)") + petrol: Union[StrictFloat, StrictInt] = Field(description="Petrol usage in L (litres)") + lpg: Union[StrictFloat, StrictInt] = Field(description="LPG Fuel usage in L (litres)") + refrigerants: List[PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner] + transports: List[PostWildseafisheriesRequestEnterprisesInnerTransportsInner] = Field(description="Transportation") + flights: List[PostWildseafisheriesRequestEnterprisesInnerFlightsInner] = Field(description="CommercialFlight") + bait: List[PostWildseafisheriesRequestEnterprisesInnerBaitInner] = Field(description="Bait") + custombait: List[PostWildseafisheriesRequestEnterprisesInnerCustombaitInner] = Field(description="Custom bait") + carbon_offset: Union[StrictFloat, StrictInt] = Field(description="Carbon offsets purchased, in t CO2. Offsetting 2 t CO2 would be 2.0 (not -2.0)", alias="carbonOffset") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "state", "electricitySource", "electricityRenewable", "electricityUse", "totalWholeWeightCaught", "diesel", "petrol", "lpg", "refrigerants", "transports", "flights", "bait", "custombait", "carbonOffset"] + + @field_validator('state') + def state_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act']): + raise ValueError("must be one of enum values ('nsw', 'vic', 'qld', 'sa', 'wa_nw', 'wa_sw', 'tas', 'nt', 'act')") + return value + + @field_validator('electricity_source') + def electricity_source_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['State Grid', 'Renewable']): + raise ValueError("must be one of enum values ('State Grid', 'Renewable')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in refrigerants (list) + _items = [] + if self.refrigerants: + for _item_refrigerants in self.refrigerants: + if _item_refrigerants: + _items.append(_item_refrigerants.to_dict()) + _dict['refrigerants'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in transports (list) + _items = [] + if self.transports: + for _item_transports in self.transports: + if _item_transports: + _items.append(_item_transports.to_dict()) + _dict['transports'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in flights (list) + _items = [] + if self.flights: + for _item_flights in self.flights: + if _item_flights: + _items.append(_item_flights.to_dict()) + _dict['flights'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in bait (list) + _items = [] + if self.bait: + for _item_bait in self.bait: + if _item_bait: + _items.append(_item_bait.to_dict()) + _dict['bait'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in custombait (list) + _items = [] + if self.custombait: + for _item_custombait in self.custombait: + if _item_custombait: + _items.append(_item_custombait.to_dict()) + _dict['custombait'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "state": obj.get("state"), + "electricitySource": obj.get("electricitySource"), + "electricityRenewable": obj.get("electricityRenewable"), + "electricityUse": obj.get("electricityUse"), + "totalWholeWeightCaught": obj.get("totalWholeWeightCaught"), + "diesel": obj.get("diesel"), + "petrol": obj.get("petrol"), + "lpg": obj.get("lpg"), + "refrigerants": [PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner.from_dict(_item) for _item in obj["refrigerants"]] if obj.get("refrigerants") is not None else None, + "transports": [PostWildseafisheriesRequestEnterprisesInnerTransportsInner.from_dict(_item) for _item in obj["transports"]] if obj.get("transports") is not None else None, + "flights": [PostWildseafisheriesRequestEnterprisesInnerFlightsInner.from_dict(_item) for _item in obj["flights"]] if obj.get("flights") is not None else None, + "bait": [PostWildseafisheriesRequestEnterprisesInnerBaitInner.from_dict(_item) for _item in obj["bait"]] if obj.get("bait") is not None else None, + "custombait": [PostWildseafisheriesRequestEnterprisesInnerCustombaitInner.from_dict(_item) for _item in obj["custombait"]] if obj.get("custombait") is not None else None, + "carbonOffset": obj.get("carbonOffset") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_bait_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_bait_inner.py new file mode 100644 index 00000000..955344bc --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_bait_inner.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInnerBaitInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInnerBaitInner + """ # noqa: E501 + type: StrictStr = Field(description="Bait product type") + purchased: Union[StrictFloat, StrictInt] = Field(description="Purchased product in tonnes") + additional_ingredient: Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Additional ingredient fraction, from 0 to 1", alias="additionalIngredient") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of product, in kg CO2e/kg", alias="emissionsIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "purchased", "additionalIngredient", "emissionsIntensity"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Fish Frames', 'Fish Heads', 'Sardines', 'Squid', 'Whole Fish']): + raise ValueError("must be one of enum values ('Fish Frames', 'Fish Heads', 'Sardines', 'Squid', 'Whole Fish')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerBaitInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerBaitInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "purchased": obj.get("purchased"), + "additionalIngredient": obj.get("additionalIngredient"), + "emissionsIntensity": obj.get("emissionsIntensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_custombait_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_custombait_inner.py new file mode 100644 index 00000000..e051cd0b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_custombait_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInnerCustombaitInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInnerCustombaitInner + """ # noqa: E501 + purchased: Union[StrictFloat, StrictInt] = Field(description="Purchased product in tonnes") + emissions_intensity: Union[StrictFloat, StrictInt] = Field(description="Emissions intensity of product, in kg CO2e/kg", alias="emissionsIntensity") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["purchased", "emissionsIntensity"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerCustombaitInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerCustombaitInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "purchased": obj.get("purchased"), + "emissionsIntensity": obj.get("emissionsIntensity") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_flights_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_flights_inner.py new file mode 100644 index 00000000..14c081bc --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_flights_inner.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInnerFlightsInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInnerFlightsInner + """ # noqa: E501 + commercial_flight_passengers: Union[StrictFloat, StrictInt] = Field(description="Commercial flight passengers per year", alias="commercialFlightPassengers") + total_flight_distance: Union[StrictFloat, StrictInt] = Field(description="Total commercial flight distance in km", alias="totalFlightDistance") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["commercialFlightPassengers", "totalFlightDistance"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerFlightsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerFlightsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "commercialFlightPassengers": obj.get("commercialFlightPassengers"), + "totalFlightDistance": obj.get("totalFlightDistance") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_refrigerants_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_refrigerants_inner.py new file mode 100644 index 00000000..6874d825 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_refrigerants_inner.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner + """ # noqa: E501 + refrigerant: StrictStr = Field(description="Refrigerant type") + annual_recharge: Union[StrictFloat, StrictInt] = Field(description="Amount of refrigerant annually recharged, kg product/year", alias="annualRecharge") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["refrigerant", "annualRecharge"] + + @field_validator('refrigerant') + def refrigerant_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A']): + raise ValueError("must be one of enum values ('HFC-23', 'HFC-32', 'HFC-41', 'HFC-43-10mee', 'HFC-125', 'HFC-134', 'HFC-134a', 'HFC-143', 'HFC-143a', 'HFC-152a', 'HFC-227ea', 'HFC-236fa', 'HFC-245ca', 'HFC-245fa', 'HFC-365mfc', 'R438A', 'R448A', 'R-22', 'Ammonia (R-717)', 'R-11', 'R-12', 'R-13', 'R-23', 'R-32', 'R-113', 'R-114', 'R-115', 'R-116', 'R-123', 'R-124', 'R-125', 'R-134a', 'R-141b', 'R-142b', 'R-143a', 'R-152a', 'R-218', 'R-227ea', 'R-236fa', 'R-245ca', 'R-245fa', 'R-C318', 'R-401A', 'R-401B', 'R-401C', 'R-402A', 'R-402B', 'R-403A', 'R-403B', 'R-404A', 'R-405A', 'R-406A', 'R-407A', 'R-407B', 'R-407C', 'R-407D', 'R-407E', 'R-408A', 'R-409A', 'R-409B', 'R-410A', 'R-411A', 'R-411B', 'R-412A', 'R-413A', 'R-414A', 'R-414B', 'R-415A', 'R-415B', 'R-416A', 'R-417A', 'R-418A', 'R-419A', 'R-420A', 'R-421A', 'R-421B', 'R-422A', 'R-422B', 'R-422C', 'R-422D', 'R-423A', 'R-424A', 'R-425A', 'R-426A', 'R-427A', 'R-428A', 'R-500', 'R-502', 'R-503', 'R-507A', 'R-508A', 'R-508B', 'R-509A')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerRefrigerantsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "refrigerant": obj.get("refrigerant"), + "annualRecharge": obj.get("annualRecharge") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_transports_inner.py b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_transports_inner.py new file mode 100644 index 00000000..6f31aa2b --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/models/post_wildseafisheries_request_enterprises_inner_transports_inner.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + +class PostWildseafisheriesRequestEnterprisesInnerTransportsInner(BaseModel): + """ + PostWildseafisheriesRequestEnterprisesInnerTransportsInner + """ # noqa: E501 + type: StrictStr = Field(description="Transport type") + fuel: StrictStr = Field(description="Fuel type") + distance: Union[StrictFloat, StrictInt] = Field(description="Distance in km") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type", "fuel", "distance"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['None', 'Small Car', 'Medium Car', 'Large Car', 'Courier Van-Utility', '4WD Mid Size', 'Light Rigid', 'Medium Rigid', 'Heavy Rigid', 'Heavy Bus']): + raise ValueError("must be one of enum values ('None', 'Small Car', 'Medium Car', 'Large Car', 'Courier Van-Utility', '4WD Mid Size', 'Light Rigid', 'Medium Rigid', 'Heavy Rigid', 'Heavy Bus')") + return value + + @field_validator('fuel') + def fuel_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['Gasoline', 'Diesel oil', 'Liquefied petroleum gas (LPG)', 'Fuel oil', 'Ethanol', 'Biodiesel', 'Renewable diesel', 'Other biofuels', 'Liquified natural gas']): + raise ValueError("must be one of enum values ('Gasoline', 'Diesel oil', 'Liquefied petroleum gas (LPG)', 'Fuel oil', 'Ethanol', 'Biodiesel', 'Renewable diesel', 'Other biofuels', 'Liquified natural gas')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerTransportsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PostWildseafisheriesRequestEnterprisesInnerTransportsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "fuel": obj.get("fuel"), + "distance": obj.get("distance") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/examples/python-api-client/api-client/openapi_client/py.typed b/examples/python-api-client/api-client/openapi_client/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/examples/python-api-client/api-client/openapi_client/rest.py b/examples/python-api-client/api-client/openapi_client/rest.py new file mode 100644 index 00000000..ccc62943 --- /dev/null +++ b/examples/python-api-client/api-client/openapi_client/rest.py @@ -0,0 +1,259 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import io +import json +import re +import ssl + +import urllib3 + +from openapi_client.exceptions import ApiException, ApiValueError + +SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} +RESTResponseType = urllib3.HTTPResponse + + +def is_socks_proxy_url(url): + if url is None: + return False + split_section = url.split("://") + if len(split_section) < 2: + return False + else: + return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.response = resp + self.status = resp.status + self.reason = resp.reason + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.data + return self.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration) -> None: + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + "ca_cert_data": configuration.ca_cert_data, + } + if configuration.assert_hostname is not None: + pool_args['assert_hostname'] = ( + configuration.assert_hostname + ) + + if configuration.retries is not None: + pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + pool_args['socket_options'] = configuration.socket_options + + if configuration.connection_pool_maxsize is not None: + pool_args['maxsize'] = configuration.connection_pool_maxsize + + # https pool manager + self.pool_manager: urllib3.PoolManager + + if configuration.proxy: + if is_socks_proxy_url(configuration.proxy): + from urllib3.contrib.socks import SOCKSProxyManager + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) + else: + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) + else: + self.pool_manager = urllib3.PoolManager(**pool_args) + + def request( + self, + method, + url, + headers=None, + body=None, + post_params=None, + _request_timeout=None + ): + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in [ + 'GET', + 'HEAD', + 'DELETE', + 'POST', + 'PUT', + 'PATCH', + 'OPTIONS' + ] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, float)): + timeout = urllib3.Timeout(total=_request_timeout) + elif ( + isinstance(_request_timeout, tuple) + and len(_request_timeout) == 2 + ): + timeout = urllib3.Timeout( + connect=_request_timeout[0], + read=_request_timeout[1] + ) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + + # no content type provided or payload is json + content_type = headers.get('Content-Type') + if ( + not content_type + or re.search('json', content_type, re.IGNORECASE) + ): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, + url, + body=request_body, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif content_type == 'application/x-www-form-urlencoded': + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=False, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif content_type == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + # Ensures that dict objects are serialized + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] + r = self.pool_manager.request( + method, + url, + fields=post_params, + encode_multipart=True, + timeout=timeout, + headers=headers, + preload_content=False + ) + # Pass a `string` parameter directly in the body to support + # other content types than JSON when `body` argument is + # provided in serialized form. + elif isinstance(body, str) or isinstance(body, bytes): + r = self.pool_manager.request( + method, + url, + body=body, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif headers['Content-Type'].startswith('text/') and isinstance(body, bool): + request_body = "true" if body else "false" + r = self.pool_manager.request( + method, + url, + body=request_body, + preload_content=False, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request( + method, + url, + fields={}, + timeout=timeout, + headers=headers, + preload_content=False + ) + except urllib3.exceptions.SSLError as e: + msg = "\n".join([type(e).__name__, str(e)]) + raise ApiException(status=0, reason=msg) + + return RESTResponse(r) diff --git a/examples/python-api-client/api-client/pyproject.toml b/examples/python-api-client/api-client/pyproject.toml new file mode 100644 index 00000000..a8d93f0b --- /dev/null +++ b/examples/python-api-client/api-client/pyproject.toml @@ -0,0 +1,95 @@ +[project] +name = "openapi_client" +version = "1.0.0" +description = "AIA Calculator API" +authors = [ + {name = "AIA",email = "contact@aginnovationaustralia.com.au"}, +] +license = "CC-BY-ND-4.0" +readme = "README.md" +keywords = ["OpenAPI", "OpenAPI-Generator", "AIA Calculator API"] +requires-python = ">=3.9" + +dependencies = [ + "urllib3 (>=2.1.0,<3.0.0)", + "python-dateutil (>=2.8.2)", + "pydantic (>=2)", + "typing-extensions (>=4.7.1)" +] + +[project.urls] +Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" + +[tool.poetry] +requires-poetry = ">=2.0" + +[tool.poetry.group.dev.dependencies] +pytest = ">= 7.2.1" +pytest-cov = ">= 2.8.1" +tox = ">= 3.9.0" +flake8 = ">= 4.0.0" +types-python-dateutil = ">= 2.8.19.14" +mypy = ">= 1.5" + + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "openapi_client", + #"test", # auto-generated tests + "tests", # hand-written tests +] +# TODO: enable "strict" once all these individual checks are passing +# strict = true + +# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + +## Getting these passing should be easy +strict_equality = true +extra_checks = true + +## Strongly recommend enabling this one as soon as you can +check_untyped_defs = true + +## These shouldn't be too much additional work, but may be tricky to +## get passing if you use a lot of untyped libraries +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true + +### These next few are various gradations of forcing use of type annotations +#disallow_untyped_calls = true +#disallow_incomplete_defs = true +#disallow_untyped_defs = true +# +### This one isn't too hard to get passing, but return on investment is lower +#no_implicit_reexport = true +# +### This one can be tricky to get passing if you use a lot of untyped libraries +#warn_return_any = true + +[[tool.mypy.overrides]] +module = [ + "openapi_client.configuration", +] +warn_unused_ignores = true +strict_equality = true +extra_checks = true +check_untyped_defs = true +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true +disallow_untyped_calls = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_reexport = true +warn_return_any = true diff --git a/examples/python-api-client/api-client/requirements.txt b/examples/python-api-client/api-client/requirements.txt new file mode 100644 index 00000000..6cbb2b98 --- /dev/null +++ b/examples/python-api-client/api-client/requirements.txt @@ -0,0 +1,4 @@ +urllib3 >= 2.1.0, < 3.0.0 +python_dateutil >= 2.8.2 +pydantic >= 2 +typing-extensions >= 4.7.1 diff --git a/examples/python-api-client/api-client/run_test.sh b/examples/python-api-client/api-client/run_test.sh new file mode 100755 index 00000000..c75860b2 --- /dev/null +++ b/examples/python-api-client/api-client/run_test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Quick run script for testing the API client +# This script activates the virtual environment and runs the test + +set -e + +# Check if virtual environment exists +if [ ! -d "venv" ]; then + echo "Virtual environment not found. Please run ./setup_local.sh first" + exit 1 +fi + +# Activate virtual environment +echo "Activating virtual environment..." +source venv/bin/activate + +# Run the test script +echo "Running API test script..." +python test_api.py + +echo "" +echo "Test complete! Virtual environment is still active." +echo "To deactivate: deactivate" + diff --git a/examples/python-api-client/api-client/setup.cfg b/examples/python-api-client/api-client/setup.cfg new file mode 100644 index 00000000..11433ee8 --- /dev/null +++ b/examples/python-api-client/api-client/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/examples/python-api-client/api-client/setup.py b/examples/python-api-client/api-client/setup.py new file mode 100644 index 00000000..5b07dd88 --- /dev/null +++ b/examples/python-api-client/api-client/setup.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + AIA Calculator API + + Emissions Calculators for various farming activities + + The version of the OpenAPI document: 3.0.0 + Contact: contact@aginnovationaustralia.com.au + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from setuptools import setup, find_packages # noqa: H301 + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools +NAME = "openapi-client" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">= 3.9" +REQUIRES = [ + "urllib3 >= 2.1.0, < 3.0.0", + "python-dateutil >= 2.8.2", + "pydantic >= 2", + "typing-extensions >= 4.7.1", +] + +setup( + name=NAME, + version=VERSION, + description="AIA Calculator API", + author="AIA", + author_email="contact@aginnovationaustralia.com.au", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "AIA Calculator API"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + license="CC-BY-ND-4.0", + long_description_content_type='text/markdown', + long_description="""\ + Emissions Calculators for various farming activities + """, # noqa: E501 + package_data={"openapi_client": ["py.typed"]}, +) \ No newline at end of file diff --git a/examples/python-api-client/api-client/setup_local.sh b/examples/python-api-client/api-client/setup_local.sh new file mode 100755 index 00000000..17f898b0 --- /dev/null +++ b/examples/python-api-client/api-client/setup_local.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Setup script for local development and testing of the API client +# This script creates a virtual environment and installs the client locally + +set -e + +echo "Setting up Python API client for local development..." + +# Check if Python 3.9+ is available +python_version=$(python3 --version 2>&1 | grep -o '[0-9]\+\.[0-9]\+' | head -1) +required_version="3.9" + +if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then + echo "Error: Python 3.9+ is required, but found Python $python_version" + echo "Please install Python 3.9 or later" + exit 1 +fi + +# Create virtual environment if it doesn't exist +if [ ! -d "venv" ]; then + echo "Creating virtual environment..." + python3 -m venv venv +else + echo "Virtual environment already exists" +fi + +# Activate virtual environment +echo "Activating virtual environment..." +source venv/bin/activate + +# Upgrade pip +echo "Upgrading pip..." +pip install --upgrade pip + +# Install the client in development mode +echo "Installing API client in development mode..." +pip install -e . + +# Install additional dependencies for testing +echo "Installing additional dependencies..." +pip install pytest + +echo "" +echo "Setup complete! To use the API client:" +echo "1. Activate the virtual environment: source venv/bin/activate" +echo "2. Run the test script: python test_api.py" +echo "3. Or run tests: pytest" +echo "" +echo "To deactivate the virtual environment when done: deactivate" + diff --git a/examples/python-api-client/api-client/test-requirements.txt b/examples/python-api-client/api-client/test-requirements.txt new file mode 100644 index 00000000..e98555c1 --- /dev/null +++ b/examples/python-api-client/api-client/test-requirements.txt @@ -0,0 +1,6 @@ +pytest >= 7.2.1 +pytest-cov >= 2.8.1 +tox >= 3.9.0 +flake8 >= 4.0.0 +types-python-dateutil >= 2.8.19.14 +mypy >= 1.5 diff --git a/examples/python-api-client/api-client/test_api.py b/examples/python-api-client/api-client/test_api.py new file mode 100755 index 00000000..7c8b0cc4 --- /dev/null +++ b/examples/python-api-client/api-client/test_api.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +""" +Test script for the AIA Calculator API client +This script demonstrates how to use the generated API client locally +""" + +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +def create_valid_beef_input(): + """Create a valid beef input using from_dict methods""" + + # Create sample data for a beef cattle operation + # This structure matches PostBeefRequest model requirements + beef_data = { + "state": "qld", # Queensland (must be valid enum: nsw, vic, qld, sa, wa_nw, wa_sw, tas, nt, act) + "northOfTropicOfCapricorn": True, + "rainfallAbove600": True, + "beef": [ + { + "id": "beef_cattle_001", + "classes": { + # Example: Cows greater than 2 years old + "cowsGt2": { + "spring": { + "head": 50, # number of animals + "liveweight": 450, # average kg/head + "liveweightGain": 0.5, # kg/day + "crudeProtein": None, # optional + "dryMatterDigestibility": None # optional + }, + "summer": { + "head": 50, + "liveweight": 440, + "liveweightGain": 0.3, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "autumn": { + "head": 50, + "liveweight": 460, + "liveweightGain": 0.4, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "winter": { + "head": 50, + "liveweight": 450, + "liveweightGain": 0.4, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "headSold": 25, # required: number sold + "saleWeight": 500, # required: weight at sale in kg/head + "headPurchased": None, # optional + "purchasedWeight": None, # optional + "source": None, # optional + "purchases": None # optional + } + }, + "limestone": 10.0, + "limestoneFraction": 0.8, # Fraction between 0 and 1 + "fertiliser": { + "singleSuperphosphate": 5.0, + "pastureDryland": 10.0, + "pastureIrrigated": 2.0, + "cropsDryland": 8.0, + "cropsIrrigated": 1.0, + "otherDryland": None, + "otherIrrigated": None, + "otherType": None, + "otherFertilisers": None + }, + "diesel": 1000, + "petrol": 200, + "lpg": 100, + "mineralSupplementation": { + "mineralBlock": 2.0, + "mineralBlockUrea": 0.3, + "weanerBlock": 1.0, + "weanerBlockUrea": 0.2, + "drySeasonMix": 1.5, + "drySeasonMixUrea": 0.25 + }, + "electricitySource": "State Grid", # Must be 'State Grid' or 'Renewable' + "electricityRenewable": 0.2, # Fraction between 0 and 1 + "electricityUse": 5000, # kWh + "grainFeed": 10.0, # tonnes + "hayFeed": 5.0, + "cottonseedFeed": 2.0, + "herbicide": 50.0, # kg + "herbicideOther": 20.0, + "cowsCalving": { + "spring": 0.2, + "summer": 0.1, + "autumn": 0.5, + "winter": 0.2 + } + } + ], + "burning": [], # List of burning activities (optional) + "vegetation": [] # List of vegetation activities (optional) + } + + beef_input = openapi_client.PostBeefRequest.from_dict(beef_data) + return beef_input + +def test_beef_api(): + """Test the beef API endpoint with valid input""" + + configuration = openapi_client.Configuration( + host="https://emissionscalculator-mtls.staging.aiaapi.com/calculator/3.0.0", + cert_file="cert.pem", + key_file="key.pem", + ) + + # Create a valid beef input + beef_input = create_valid_beef_input() + + print("Created beef input:") + print("=" * 50) + pprint(beef_input.to_dict()) + print("=" * 50) + + with openapi_client.ApiClient(configuration) as api_client: + api_instance = openapi_client.GAFApi(api_client) + + try: + print("Calling beef API...") + api_response = api_instance.post_beef(beef_input) + print("The response of GAFApi->post_beef:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling GAFApi->post_beef: %s\n" % e) + print("This is expected if you don't have proper authentication configured") + +def main(): + """Main function to run API tests""" + print("Testing AIA Calculator API Client") + print("=" * 40) + + # Test beef endpoint + test_beef_api() + print("\n" + "=" * 40) + + print("API testing complete!") + print("\nNote: Authentication errors are expected if you haven't configured") + print("proper credentials for the production API endpoint.") + +if __name__ == "__main__": + main() diff --git a/examples/python-api-client/api-client/tox.ini b/examples/python-api-client/api-client/tox.ini new file mode 100644 index 00000000..1a9028b7 --- /dev/null +++ b/examples/python-api-client/api-client/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=openapi_client diff --git a/examples/python-api-client/generate.sh b/examples/python-api-client/generate.sh new file mode 100755 index 00000000..693e696c --- /dev/null +++ b/examples/python-api-client/generate.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e +API_CLIENT_DIR=api-client +API_VERSION=3.0.0 +rm -rf $API_CLIENT_DIR + +npm -g install @openapitools/openapi-generator-cli +openapi-generator-cli generate \ + -i https://d2awla29kxgk7i.cloudfront.net/api/$API_VERSION/openapi.json \ + -g python \ + -o $API_CLIENT_DIR \ + --global-property apiTests=false,apiDocs=false,modelTests=false,modelDocs=false + +cp resources/* $API_CLIENT_DIR/ + +cd $API_CLIENT_DIR +./setup_local.sh +./run_test.sh \ No newline at end of file diff --git a/examples/python-api-client/resources/run_test.sh b/examples/python-api-client/resources/run_test.sh new file mode 100755 index 00000000..c75860b2 --- /dev/null +++ b/examples/python-api-client/resources/run_test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Quick run script for testing the API client +# This script activates the virtual environment and runs the test + +set -e + +# Check if virtual environment exists +if [ ! -d "venv" ]; then + echo "Virtual environment not found. Please run ./setup_local.sh first" + exit 1 +fi + +# Activate virtual environment +echo "Activating virtual environment..." +source venv/bin/activate + +# Run the test script +echo "Running API test script..." +python test_api.py + +echo "" +echo "Test complete! Virtual environment is still active." +echo "To deactivate: deactivate" + diff --git a/examples/python-api-client/resources/setup_local.sh b/examples/python-api-client/resources/setup_local.sh new file mode 100755 index 00000000..17f898b0 --- /dev/null +++ b/examples/python-api-client/resources/setup_local.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Setup script for local development and testing of the API client +# This script creates a virtual environment and installs the client locally + +set -e + +echo "Setting up Python API client for local development..." + +# Check if Python 3.9+ is available +python_version=$(python3 --version 2>&1 | grep -o '[0-9]\+\.[0-9]\+' | head -1) +required_version="3.9" + +if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then + echo "Error: Python 3.9+ is required, but found Python $python_version" + echo "Please install Python 3.9 or later" + exit 1 +fi + +# Create virtual environment if it doesn't exist +if [ ! -d "venv" ]; then + echo "Creating virtual environment..." + python3 -m venv venv +else + echo "Virtual environment already exists" +fi + +# Activate virtual environment +echo "Activating virtual environment..." +source venv/bin/activate + +# Upgrade pip +echo "Upgrading pip..." +pip install --upgrade pip + +# Install the client in development mode +echo "Installing API client in development mode..." +pip install -e . + +# Install additional dependencies for testing +echo "Installing additional dependencies..." +pip install pytest + +echo "" +echo "Setup complete! To use the API client:" +echo "1. Activate the virtual environment: source venv/bin/activate" +echo "2. Run the test script: python test_api.py" +echo "3. Or run tests: pytest" +echo "" +echo "To deactivate the virtual environment when done: deactivate" + diff --git a/examples/python-api-client/resources/test_api.py b/examples/python-api-client/resources/test_api.py new file mode 100755 index 00000000..7c8b0cc4 --- /dev/null +++ b/examples/python-api-client/resources/test_api.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +""" +Test script for the AIA Calculator API client +This script demonstrates how to use the generated API client locally +""" + +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +def create_valid_beef_input(): + """Create a valid beef input using from_dict methods""" + + # Create sample data for a beef cattle operation + # This structure matches PostBeefRequest model requirements + beef_data = { + "state": "qld", # Queensland (must be valid enum: nsw, vic, qld, sa, wa_nw, wa_sw, tas, nt, act) + "northOfTropicOfCapricorn": True, + "rainfallAbove600": True, + "beef": [ + { + "id": "beef_cattle_001", + "classes": { + # Example: Cows greater than 2 years old + "cowsGt2": { + "spring": { + "head": 50, # number of animals + "liveweight": 450, # average kg/head + "liveweightGain": 0.5, # kg/day + "crudeProtein": None, # optional + "dryMatterDigestibility": None # optional + }, + "summer": { + "head": 50, + "liveweight": 440, + "liveweightGain": 0.3, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "autumn": { + "head": 50, + "liveweight": 460, + "liveweightGain": 0.4, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "winter": { + "head": 50, + "liveweight": 450, + "liveweightGain": 0.4, + "crudeProtein": None, + "dryMatterDigestibility": None + }, + "headSold": 25, # required: number sold + "saleWeight": 500, # required: weight at sale in kg/head + "headPurchased": None, # optional + "purchasedWeight": None, # optional + "source": None, # optional + "purchases": None # optional + } + }, + "limestone": 10.0, + "limestoneFraction": 0.8, # Fraction between 0 and 1 + "fertiliser": { + "singleSuperphosphate": 5.0, + "pastureDryland": 10.0, + "pastureIrrigated": 2.0, + "cropsDryland": 8.0, + "cropsIrrigated": 1.0, + "otherDryland": None, + "otherIrrigated": None, + "otherType": None, + "otherFertilisers": None + }, + "diesel": 1000, + "petrol": 200, + "lpg": 100, + "mineralSupplementation": { + "mineralBlock": 2.0, + "mineralBlockUrea": 0.3, + "weanerBlock": 1.0, + "weanerBlockUrea": 0.2, + "drySeasonMix": 1.5, + "drySeasonMixUrea": 0.25 + }, + "electricitySource": "State Grid", # Must be 'State Grid' or 'Renewable' + "electricityRenewable": 0.2, # Fraction between 0 and 1 + "electricityUse": 5000, # kWh + "grainFeed": 10.0, # tonnes + "hayFeed": 5.0, + "cottonseedFeed": 2.0, + "herbicide": 50.0, # kg + "herbicideOther": 20.0, + "cowsCalving": { + "spring": 0.2, + "summer": 0.1, + "autumn": 0.5, + "winter": 0.2 + } + } + ], + "burning": [], # List of burning activities (optional) + "vegetation": [] # List of vegetation activities (optional) + } + + beef_input = openapi_client.PostBeefRequest.from_dict(beef_data) + return beef_input + +def test_beef_api(): + """Test the beef API endpoint with valid input""" + + configuration = openapi_client.Configuration( + host="https://emissionscalculator-mtls.staging.aiaapi.com/calculator/3.0.0", + cert_file="cert.pem", + key_file="key.pem", + ) + + # Create a valid beef input + beef_input = create_valid_beef_input() + + print("Created beef input:") + print("=" * 50) + pprint(beef_input.to_dict()) + print("=" * 50) + + with openapi_client.ApiClient(configuration) as api_client: + api_instance = openapi_client.GAFApi(api_client) + + try: + print("Calling beef API...") + api_response = api_instance.post_beef(beef_input) + print("The response of GAFApi->post_beef:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling GAFApi->post_beef: %s\n" % e) + print("This is expected if you don't have proper authentication configured") + +def main(): + """Main function to run API tests""" + print("Testing AIA Calculator API Client") + print("=" * 40) + + # Test beef endpoint + test_beef_api() + print("\n" + "=" * 40) + + print("API testing complete!") + print("\nNote: Authentication errors are expected if you haven't configured") + print("proper credentials for the production API endpoint.") + +if __name__ == "__main__": + main()